Class Strings
java.lang.Object
ac.simons.neo4j.migrations.core.internal.Strings
Internally used String utilities. There are no guarantees on the stability of this API. It won't be available when
run on the module path.
- Since:
- 1.2.2
- Author:
- Michael J. Simon
-
Field Summary
FieldsModifier and TypeFieldDescriptionA Base64 encoder.static final String
Single line comment indicator.static final String
Pattern used for splitting lines.static final UnaryOperator<byte[]>
Function for creating an MD5 representation of a byte array. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
capitalize
(String value) Capitalizes a stringstatic String
escapeIfNecessary
(String potentiallyNonIdentifier) Escapes the string potentiallyNonIdentifier in all cases when it's not a valid Cypher identifier.static boolean
static boolean
isIdentifier
(CharSequence name) This is a literal copy ofjavax.lang.model.SourceVersion#isIdentifier(CharSequence)
included here to be not dependent on the compiler module.static boolean
isSingleLineComment
(String statement) This won't match a statement likeoptionalOf
(String value) Creates an optional value from a given string value, filtering additionally on blankness.static String
toCamelCase
(String value) Transforms a string with words separated by _ into a camelCase string.
-
Field Details
-
CYPHER_SINGLE_LINE_COMMENT
Single line comment indicator.- See Also:
-
LINE_DELIMITER
Pattern used for splitting lines.- See Also:
-
MD5
Function for creating an MD5 representation of a byte array. -
BASE64_ENCODING
A Base64 encoder.
-
-
Method Details
-
capitalize
Capitalizes a string- Parameters:
value
- String to capitalize- Returns:
- Capitalized String or the original value if unchanged or if the value was null or empty.
-
toCamelCase
Transforms a string with words separated by _ into a camelCase string.- Parameters:
value
- The value to transform- Returns:
- the value in camelCase
-
isSingleLineComment
This won't match a statement like// Right at the start MATCH (n) RETURN count(n) AS n;
which will pe extracted from a Cypher file as one statement starting with a comment.It would be nice to use the JavaCC Parser here as we do in Cypher-DSL, but that would require Java 11 for core.
- Parameters:
statement
- A statement to check- Returns:
- True if the statement is not null and is a single line comment
-
optionalOf
Creates an optional value from a given string value, filtering additionally on blankness.- Parameters:
value
- The value to create an optional from- Returns:
- An optional
-
isBlank
- Parameters:
value
- The value to check- Returns:
- true if
value
is null or completely blank.
-
isIdentifier
This is a literal copy ofjavax.lang.model.SourceVersion#isIdentifier(CharSequence)
included here to be not dependent on the compiler module.- Parameters:
name
- A possible Java identifier- Returns:
- True, if
name
represents an identifier.
-
escapeIfNecessary
Escapes the string potentiallyNonIdentifier in all cases when it's not a valid Cypher identifier.- Parameters:
potentiallyNonIdentifier
- A value to escape- Returns:
- The escaped value or the same value if no escaping is necessary.
-