public class GriffonNameUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
capitalize(java.lang.String str)
Capitalizes a String (makes the first char uppercase) taking care
of blank strings and single character strings.
|
static java.lang.String |
getClassName(java.lang.String logicalName,
java.lang.String trailingName)
Returns the class name for the given logical name and trailing name.
|
static java.lang.String |
getClassNameForLowerCaseHyphenSeparatedName(java.lang.String name)
Converts foo-bar into FooBar.
|
static java.lang.String |
getClassNameRepresentation(java.lang.String name)
Returns the class name representation of the given name
|
static java.lang.String |
getGetterName(java.lang.String propertyName)
Calculate the name for a getter method to retrieve the specified property
|
static java.lang.String |
getHyphenatedName(java.lang.Class<?> clazz)
Retrieves the hyphenated name representation of the supplied class.
|
static java.lang.String |
getHyphenatedName(java.lang.String name)
Retrieves the hyphenated name representation of the given class name.
|
static java.lang.String |
getLogicalName(java.lang.Class<?> clazz,
java.lang.String trailingName)
Retrieves the logical class name of a Griffon artifact given the Griffon class
and a specified trailing name
|
static java.lang.String |
getLogicalName(java.lang.String name,
java.lang.String trailingName)
Retrieves the logical name of the class without the trailing name
|
static java.lang.String |
getLogicalPropertyName(java.lang.String className,
java.lang.String trailingName) |
static java.lang.String |
getNaturalName(java.lang.String name)
Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name')
|
static java.lang.String |
getPropertyName(java.lang.Class<?> clazz)
Shorter version of getPropertyNameRepresentation
|
static java.lang.String |
getPropertyName(java.lang.String name)
Shorter version of getPropertyNameRepresentation
|
static java.lang.String |
getPropertyNameForLowerCaseHyphenSeparatedName(java.lang.String name)
Converts foo-bar into fooBar
|
static java.lang.String |
getPropertyNameRepresentation(java.lang.Class<?> targetClass)
Returns the property name equivalent for the specified class
|
static java.lang.String |
getPropertyNameRepresentation(java.lang.String name)
Returns the property name representation of the given name
|
static java.lang.String |
getSetterName(java.lang.String propertyName)
Retrieves the name of a setter for the specified property name
|
static java.lang.String |
getShortName(java.lang.Class<?> targetClass)
Returns the class name without the package prefix
|
static java.lang.String |
getShortName(java.lang.String className)
Returns the class name without the package prefix
|
static boolean |
isBlank(java.lang.String str)
Determines whether a given string is
null, empty,
or only contains whitespace. |
static boolean |
isKeyword(java.lang.String str)
Finds out if the given String is a Java/Groovy keyword.
|
static boolean |
isNotBlank(java.lang.String str)
Determines whether a given string is not
null, empty,
or only contains whitespace. |
static java.lang.String |
join(java.lang.Iterable<?> self,
java.lang.String separator)
Concatenates the
toString() representation of each
item in this Iterable, with the given String as a separator between each item. |
static java.lang.String |
quote(java.lang.String str)
Applies single or double quotes to a string if it contains whitespace characters
|
static java.lang.String |
requireNonBlank(java.lang.String str)
Checks that the specified String is not
blank. |
static java.lang.String |
requireNonBlank(java.lang.String str,
java.lang.String message)
Checks that the specified String is not
blank and
throws a customized IllegalArgumentException if it is. |
static java.lang.String |
uncapitalize(java.lang.String str)
Uncapitalizes a String (makes the first char lowercase) taking care
of blank strings and single character strings.
|
static java.lang.String |
unquote(java.lang.String str)
Removes single or double quotes from a String
|
public static boolean isKeyword(java.lang.String str)
str - The String to testpublic static java.lang.String capitalize(java.lang.String str)
str - The String to be capitalizedpublic static java.lang.String uncapitalize(java.lang.String str)
str - The String to be uncapitalizedpublic static java.lang.String getSetterName(java.lang.String propertyName)
propertyName - The property namepublic static java.lang.String getGetterName(java.lang.String propertyName)
propertyName - The property namepublic static java.lang.String getClassName(java.lang.String logicalName,
java.lang.String trailingName)
logicalName - The logical nametrailingName - The trailing namepublic static java.lang.String getClassNameRepresentation(java.lang.String name)
name - The name to convertpublic static java.lang.String getClassNameForLowerCaseHyphenSeparatedName(java.lang.String name)
name - The lower case hyphen separated namepublic static java.lang.String getLogicalName(java.lang.Class<?> clazz,
java.lang.String trailingName)
clazz - The classtrailingName - The trailing name such as "Controller" or "TagLib"public static java.lang.String getLogicalName(java.lang.String name,
java.lang.String trailingName)
name - The name of the classtrailingName - The trailing namepublic static java.lang.String getLogicalPropertyName(java.lang.String className,
java.lang.String trailingName)
public static java.lang.String getPropertyName(java.lang.String name)
name - The name to convertpublic static java.lang.String getPropertyName(java.lang.Class<?> clazz)
clazz - The clazz to convertpublic static java.lang.String getPropertyNameRepresentation(java.lang.Class<?> targetClass)
targetClass - The class to get the property name forpublic static java.lang.String getPropertyNameRepresentation(java.lang.String name)
name - The name to convertpublic static java.lang.String getPropertyNameForLowerCaseHyphenSeparatedName(java.lang.String name)
name - The lower case hyphen separated namepublic static java.lang.String getShortName(java.lang.Class<?> targetClass)
targetClass - The class to get a short name forpublic static java.lang.String getShortName(java.lang.String className)
className - The class name to get a short name forpublic static java.lang.String getNaturalName(java.lang.String name)
name - The property name to convertpublic static boolean isBlank(java.lang.String str)
Determines whether a given string is null, empty,
or only contains whitespace. If it contains anything other than
whitespace then the string is not considered to be blank and the
method returns false.
str - The string to test.true if the string is null, or
blank.public static boolean isNotBlank(java.lang.String str)
Determines whether a given string is not null, empty,
or only contains whitespace. If it contains anything other than
whitespace then the string is not considered to be blank and the
method returns true.
str - The string to test.true if the string is not null, nor
blank.public static java.lang.String requireNonBlank(java.lang.String str)
blank. This
method is designed primarily for doing parameter validation in methods
and constructors, as demonstrated below:
public Foo(String str) {
this.str = GriffonNameUtils.requireNonBlank(str);
}
str - the String to check for blankstr if not blankjava.lang.IllegalArgumentException - if str is blankpublic static java.lang.String requireNonBlank(java.lang.String str,
java.lang.String message)
blank and
throws a customized IllegalArgumentException if it is. This method
is designed primarily for doing parameter validation in methods and
constructors with multiple parameters, as demonstrated below:
public Foo(String str) {
this.str = GriffonNameUtils.requireNonBlank(str, "str must not be null");
}
str - the String to check for blankmessage - detail message to be used in the event that a IllegalArgumentException is thrownstr if not blankjava.lang.IllegalArgumentException - if str is blankpublic static java.lang.String getHyphenatedName(java.lang.Class<?> clazz)
clazz - The class to convertpublic static java.lang.String getHyphenatedName(java.lang.String name)
name - The class name to convert.@Nonnull
public static java.lang.String join(@Nonnull
java.lang.Iterable<?> self,
@Nullable
java.lang.String separator)
toString() representation of each
item in this Iterable, with the given String as a separator between each item.self - an Iterable of objectsseparator - a String separatorpublic static java.lang.String quote(java.lang.String str)
str - the String to be surrounded by quotespublic static java.lang.String unquote(java.lang.String str)
str - the String from which quotes will be removed