public final class Util extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
NEVER_MATCH
A pattern that never matches (and does so efficiently)
|
Modifier and Type | Method and Description |
---|---|
static File |
canonize(File pFile)
Calls getCanonicalFile() on the given File; if that doesn't work, call getAbsoluteFile() on it.
|
static void |
closeQuietly(Closeable pCloseable)
Quietly close the given resource, ignoring any exceptions.
|
static DetailAST |
findLeftMostTokenInLine(DetailAST pAst)
Find the left-most token in the given AST.
|
static String |
getFirstIdent(DetailAST pAst)
Determine the text of the first direct IDENT child node.
|
static String |
getFullIdent(DetailAST pAst)
Determine the full identifier of the current element on the AST.
|
static <E> Set<E> |
union(Set<E> pColl1,
Set<E> pColl2)
Creates a new immutable
HashSet which contains a union of the two given sets. |
static <E extends Enum<E>> |
valueOfIgnoreCase(String pValue,
Class<E> pEnumClass)
Variant of
Enum.valueOf(java.lang.Class<T>, java.lang.String) that ignores value case. |
public static final Pattern NEVER_MATCH
@CheckForNull public static String getFirstIdent(@Nonnull DetailAST pAst)
pAst
- an ASTnull
if none was found@CheckForNull public static String getFullIdent(@Nonnull DetailAST pAst)
pAst
- an ASTnull
if no
identifier could be constructedpublic static void closeQuietly(@Nullable Closeable pCloseable)
pCloseable
- the resource to close@Nonnull public static File canonize(@Nonnull File pFile)
pFile
- a file@Nonnull public static <E> Set<E> union(@Nullable Set<E> pColl1, @Nullable Set<E> pColl2)
HashSet
which contains a union of the two given sets.E
- type of all contained elementspColl1
- first setpColl2
- second set@Nonnull public static DetailAST findLeftMostTokenInLine(@Nonnull DetailAST pAst)
pAst
- the root of a subtree. This token is also considered for the result.@Nonnull public static <E extends Enum<E>> E valueOfIgnoreCase(@Nonnull String pValue, @Nonnull Class<E> pEnumClass)
Enum.valueOf(java.lang.Class<T>, java.lang.String)
that ignores value case.E
- the enum typepValue
- the String valuepEnumClass
- the class object of the enum typeIllegalArgumentException
- the given String value does not match a valid enum value