Package org.mapstruct.ap.internal.util
Class Strings
- java.lang.Object
-
- org.mapstruct.ap.internal.util.Strings
-
public class Strings extends Object
Helper class for dealing with strings.- Author:
- Gunnar Morling
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
capitalize(String string)
static String
decapitalize(String string)
static String
getMostSimilarWord(String word, Collection<String> similarWords)
static String
getSafeVariableName(String name, String... existingVariableNames)
static String
getSafeVariableName(String name, Collection<String> existingVariableNames)
Returns a variable name which doesn't conflict with the given variable names existing in the same scope and the Java keywords.static boolean
isEmpty(String string)
static boolean
isNotEmpty(String string)
static String
join(Iterable<?> iterable, String separator)
static <T> String
join(Iterable<T> iterable, String separator, Extractor<T,String> extractor)
static String
joinAndCamelize(Iterable<?> iterable)
static String
sanitizeIdentifierName(String identifier)
static String
stubPropertyName(String fullyQualifiedName)
Returns a stub property name from full class name by stripping away the package and decapitalizing the name For example will returnfooBar
forcom.foo.bar.baz.FooBar
class name
-
-
-
Method Detail
-
join
public static <T> String join(Iterable<T> iterable, String separator, Extractor<T,String> extractor)
-
isEmpty
public static boolean isEmpty(String string)
-
isNotEmpty
public static boolean isNotEmpty(String string)
-
getSafeVariableName
public static String getSafeVariableName(String name, String... existingVariableNames)
-
getSafeVariableName
public static String getSafeVariableName(String name, Collection<String> existingVariableNames)
Returns a variable name which doesn't conflict with the given variable names existing in the same scope and the Java keywords.- Parameters:
name
- the name to get a safe version forexistingVariableNames
- the names of other variables existing in the same scope- Returns:
- a variable name based on the given original name, not conflicting with any of the given other names or any Java keyword; starting with a lower-case letter
-
sanitizeIdentifierName
public static String sanitizeIdentifierName(String identifier)
- Parameters:
identifier
- identifier to sanitize- Returns:
- the identifier without any characters that are not allowed as part of a Java identifier.
-
stubPropertyName
public static String stubPropertyName(String fullyQualifiedName)
Returns a stub property name from full class name by stripping away the package and decapitalizing the name For example will returnfooBar
forcom.foo.bar.baz.FooBar
class name- Parameters:
fullyQualifiedName
- fully qualified class name, such as com.foo.bar.baz.FooBar- Returns:
- stup property name, such as fooBar
-
getMostSimilarWord
public static String getMostSimilarWord(String word, Collection<String> similarWords)
-
-