Package com.github.javaparser.utils
Class Utils
java.lang.Object
com.github.javaparser.utils.Utils
Any kind of utility.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
assertNonEmpty
(String string) static <T extends Number>
TassertNonNegative
(T number) static <T> T
assertNotNull
(T o) static <T extends Number>
TassertPositive
(T number) static String
camelCaseToScreaming
(String input) static String
capitalize
(String s) Capitalizes the first character in the string.static String
Lower-cases the first character in the string.static String
escapeEndOfLines
(String string) static boolean
Checks, if the parent is a unary expression with a minus operator.static StringBuilder
indent
(StringBuilder builder, int indentLevel) Make an indent by appending indentLevel tab characters to the builder.static <E> int
indexOfElementByObjectIdentity
(List<E> list, E o) LikeList.indexOf(Object)
, but using ==, not equals.static <E> boolean
isNullOrEmpty
(Collection<E> collection) static String
Return the next word of the string, in other words it stops when a space is encountered.static String
normalizeEolInTextBlock
(String content, LineSeparator desiredEndOfLineCharacter) static String
normalizeEolInTextBlock
(String content, String desiredEndOfLineCharacter) static String
readerToString
(Reader reader) static <E> void
removeElementByObjectIdentity
(List<E> list, E o) LikeList.remove(Object)
, but using ==, not equals.static String
removeFileExtension
(String filename) static <E> void
replaceElementByObjectIdentity
(List<E> list, E oldObject, E newObject) LikeList.set(int, Object)
atList.indexOf(Object)
, but using ==, not equals.static String
screamingToCamelCase
(String original) Transform a string to the camel case conversion.static <T> Set
<T> set
(T... items) private static String
static String
toCamelCase
(String original) Deprecated.use screamingToCamelCasestatic String
trimTrailingSpaces
(String line) LikeString.trim()
, but only the trailing spaces.static boolean
valueIsNullOrEmpty
(Object value) static boolean
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isNullOrEmpty
-
assertNotNull
public static <T> T assertNotNull(T o) -
assertNonEmpty
-
assertNonNegative
-
assertPositive
-
escapeEndOfLines
- Returns:
- string with ASCII characters 10 and 13 replaced by the text "\n" and "\r".
-
readerToString
- Throws:
IOException
-
toCamelCase
Deprecated.use screamingToCamelCase -
screamingToCamelCase
Transform a string to the camel case conversion.For example "ABC_DEF" becomes "abcDef"
-
camelCaseToScreaming
- Parameters:
input
- "aCamelCaseString"- Returns:
- "A_CAMEL_CASE_STRING"
-
nextWord
Return the next word of the string, in other words it stops when a space is encountered. -
indent
Make an indent by appending indentLevel tab characters to the builder. -
capitalize
Capitalizes the first character in the string. -
decapitalize
Lower-cases the first character in the string. -
stringTransformer
-
valueIsNullOrEmpty
- Returns:
- true if the value is null, an empty Optional, or an empty String.
-
valueIsNullOrEmptyStringOrOptional
-
replaceElementByObjectIdentity
LikeList.set(int, Object)
atList.indexOf(Object)
, but using ==, not equals. -
removeElementByObjectIdentity
LikeList.remove(Object)
, but using ==, not equals. -
indexOfElementByObjectIdentity
LikeList.indexOf(Object)
, but using ==, not equals. -
set
- Returns:
- a set of the items.
-
normalizeEolInTextBlock
- Returns:
- content, with all kinds of EOL characters replaced by desiredEndOfLineCharacter
-
normalizeEolInTextBlock
public static String normalizeEolInTextBlock(String content, LineSeparator desiredEndOfLineCharacter) - Returns:
- content, with all kinds of EOL characters replaced by desiredEndOfLineCharacter
-
removeFileExtension
- Returns:
- the filename with the last "." and everything following it removed.
-
trimTrailingSpaces
LikeString.trim()
, but only the trailing spaces. -
hasUnaryMinusAsParent
Checks, if the parent is a unary expression with a minus operator. Used to check for negative literals.
-