Top Description Fields Constructors Methods
com.github.javaparser.utils

public Class Utils

extends Object
Class Inheritance
Imports
java.io.IOException, .Reader, java.nio.file.Files, java.util.*, java.util.function.Predicate, .Function

Any kind of utility.
Author
Federico Tomassetti

Field Summary

Modifier and TypeField and Description
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
public static <T extends Number> T
public static <T> T
public static <T extends Number> T
assertPositive(T number)

public static String

Returns:

"A_CAMEL_CASE_STRING"
camelCaseToScreaming
(String
"aCamelCaseString"
input
)

public static String
capitalize(String s)

Capitalizes the first character in the string.

public static String
decapitalize(String s)

Lower-cases the first character in the string.

public static String

Returns:

string with ASCII characters 10 and 13 replaced by the text "\n" and "\r".
escapeEndOfLines
(String string)

public static StringBuilder
indent(StringBuilder builder, int indentLevel)

Make an indent by appending indentLevel tab characters to the builder.

public static <E> int
indexOfElementByObjectIdentity(List<E> list, E o)

Like List#indexOf(Object), but using ==, not equals.

public static <E> boolean
isNullOrEmpty(Collection<E> collection)

public static String
nextWord(String string)

Return the next word of the string, in other words it stops when a space is encountered.

public static String

Returns:

content with all kinds of EOL characters replaced by endOfLineCharacter
normalizeEolInTextBlock
(String content, String endOfLineCharacter)

public static String
public static <E> void
removeElementByObjectIdentity(List<E> list, E o)

Like List#remove(Object), but using ==, not equals.

public static String

Returns:

the filename with the last "." and everything following it removed.
removeFileExtension
(String filename)

public static <E> void
replaceElementByObjectIdentity(List<E> list, E oldObject, E newObject)

Like List#set(int, Object) at List#indexOf(Object), but using ==, not equals.

public static String
screamingToCamelCase(String original)

Transform a string to the camel case conversion.

public static <T> Set<T>

Returns:

a set of the items.
set
(T... items)

private static String
stringTransformer(String s, String operationDescription, Function<String, String> transformation)

public static String
toCamelCase(String original)

Deprecated use screamingToCamelCase
public static String
trimTrailingSpaces(String line)

Like String#trim(), but only the trailing spaces.

public static boolean

Returns:

true if the value is null, an empty Optional, or an empty String.
valueIsNullOrEmpty
(Object value)

public static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EOLback to summary
public static final String EOL

Constructor Detail

Utilsback to summary
public Utils()

Method Detail

assertNonEmptyback to summary
public static String assertNonEmpty(String string)
assertNonNegativeback to summary
public static <T extends Number> T assertNonNegative(T number)
assertNotNullback to summary
public static <T> T assertNotNull(T o)
assertPositiveback to summary
public static <T extends Number> T assertPositive(T number)
camelCaseToScreamingback to summary
public static String camelCaseToScreaming(String input)
Parameters
input:String

"aCamelCaseString"

Returns:String

"A_CAMEL_CASE_STRING"

capitalizeback to summary
public static String capitalize(String s)

Capitalizes the first character in the string.

decapitalizeback to summary
public static String decapitalize(String s)

Lower-cases the first character in the string.

escapeEndOfLinesback to summary
public static String escapeEndOfLines(String string)
Returns:String

string with ASCII characters 10 and 13 replaced by the text "\n" and "\r".

indentback to summary
public static StringBuilder indent(StringBuilder builder, int indentLevel)

Make an indent by appending indentLevel tab characters to the builder.

indexOfElementByObjectIdentityback to summary
public static <E> int indexOfElementByObjectIdentity(List<E> list, E o)

Like List#indexOf(Object), but using ==, not equals.

isNullOrEmptyback to summary
public static <E> boolean isNullOrEmpty(Collection<E> collection)
nextWordback to summary
public static String nextWord(String string)

Return the next word of the string, in other words it stops when a space is encountered.

normalizeEolInTextBlockback to summary
public static String normalizeEolInTextBlock(String content, String endOfLineCharacter)
Returns:String

content with all kinds of EOL characters replaced by endOfLineCharacter

readerToStringback to summary
public static String readerToString(Reader reader) throws IOException
removeElementByObjectIdentityback to summary
public static <E> void removeElementByObjectIdentity(List<E> list, E o)

Like List#remove(Object), but using ==, not equals.

removeFileExtensionback to summary
public static String removeFileExtension(String filename)
Returns:String

the filename with the last "." and everything following it removed.

replaceElementByObjectIdentityback to summary
public static <E> void replaceElementByObjectIdentity(List<E> list, E oldObject, E newObject)

Like List#set(int, Object) at List#indexOf(Object), but using ==, not equals.

screamingToCamelCaseback to summary
public static String screamingToCamelCase(String original)

Transform a string to the camel case conversion.

For example "ABC_DEF" becomes "abcDef"

setback to summary
public static <T> Set<T> set(T... items)
Returns:Set<T>

a set of the items.

Annotations
@SafeVarargs
stringTransformerback to summary
private static String stringTransformer(String s, String operationDescription, Function<String, String> transformation)
toCamelCaseback to summary
public static String toCamelCase(String original)

Deprecated

use screamingToCamelCase

trimTrailingSpacesback to summary
public static String trimTrailingSpaces(String line)

Like String#trim(), but only the trailing spaces.

valueIsNullOrEmptyback to summary
public static boolean valueIsNullOrEmpty(Object value)
Returns:boolean

true if the value is null, an empty Optional, or an empty String.

valueIsNullOrEmptyStringOrOptionalback to summary
public static boolean valueIsNullOrEmptyStringOrOptional(Object value)