public interface Util
| Modifier and Type | Method and Description |
|---|---|
String |
getQualifiedName(TypeMirror type)
Gets the qualified name for the given type.
|
String |
getRelativePath(String fromPath,
String toPath)
Gets the relative path that links the two given paths.
|
String |
getSourceFilePath(Element element)
Gets the source file path if any.
|
TypeMirror |
getType(Class<?> clazz)
Gets the type from an existing runtime class when possible (return null
when the type cannot be found in the compiler's symbol table).
|
boolean |
isCoreType(TypeMirror type)
Tells if the given type is a core type.
|
boolean |
isDeprecated(Element element)
Tells if the given element is deprecated.
|
boolean |
isIntegral(TypeMirror type)
Tells if the given type is an integral type (int, long, byte).
|
boolean |
isNumber(TypeMirror type)
Tells if the given type is a number.
|
boolean |
isSourceElement(Element element)
Tells if the given element is part of the transpiled sources.
|
String getQualifiedName(TypeMirror type)
TypeMirror getType(Class<?> clazz)
boolean isNumber(TypeMirror type)
boolean isDeprecated(Element element)
boolean isCoreType(TypeMirror type)
boolean isIntegral(TypeMirror type)
boolean isSourceElement(Element element)
String getSourceFilePath(Element element)
isSourceElement(Element)String getRelativePath(String fromPath, String toPath)
assertEquals("../c", getRelativePath("/a/b", "/a/c"));
assertEquals("..", getRelativePath("/a/b", "/a"));
assertEquals("../e", getRelativePath("/a/b/c", "/a/b/e"));
assertEquals("d", getRelativePath("/a/b/c", "/a/b/c/d"));
assertEquals("d/e", getRelativePath("/a/b/c", "/a/b/c/d/e"));
assertEquals("../../../d/e/f", getRelativePath("/a/b/c", "/d/e/f"));
assertEquals("../..", getRelativePath("/a/b/c", "/a"));
assertEquals("..", getRelativePath("/a/b/c", "/a/b"));
Thanks to: http://mrpmorris.blogspot.com/2007/05/convert-absolute-path-to-relative- path.html
Bug fix: Renaud Pawlak
fromPath - the path to start fromtoPath - the path to reach