public final class CodeStyleUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
addPrefixSuffix(CharSequence name,
String prefix,
String suffix)
Add a prefix and suffix to a name.
|
static String |
computeGetterName(CharSequence fieldName,
boolean isBoolean,
boolean isStatic,
CodeStyle cs)
Computes the method name that should be used to read the property value.
|
static String |
computeSetterName(CharSequence fieldName,
boolean isStatic,
CodeStyle cs)
Computes the method name that should be used to write the property value.
|
static String |
getCapitalizedName(CharSequence name)
Capitalize a name following the javabeans specification.
|
static String |
getDecapitalizedName(CharSequence name)
Decapitalize a name to its normal java form.
|
static String |
removePrefixSuffix(CharSequence name,
String prefix,
String suffix)
Removes a prefix and suffix from a name.
|
@NonNull public static String addPrefixSuffix(@NullAllowed CharSequence name, @NullAllowed String prefix, @NullAllowed String suffix)
name
- the name to add the Prefix and Suffix to.prefix
- the prefix to add, or null if no prefix should be added.suffix
- the suffix to add, or null if no suffix should be added.getCapitalizedName(java.lang.CharSequence)
@NonNull public static String removePrefixSuffix(@NonNull CharSequence name, @NullAllowed String prefix, @NullAllowed String suffix)
name
- the name to remove the Prefix and Suffix from.prefix
- the prefix to remove, or null if no prefix should be
removed.suffix
- the suffix to remove, or null if no suffix should be
removed.addPrefixSuffix(java.lang.CharSequence, java.lang.String,
java.lang.String)
,
getDecapitalizedName(java.lang.CharSequence)
@NonNull public static String getCapitalizedName(CharSequence name)
To stay backwards compatible, if the name starts with _ they will be removed.
name
- the name to capitalize@NonNull public static String getDecapitalizedName(@NonNull CharSequence name)
name
- the name to decapitalize@NonNull public static String computeGetterName(CharSequence fieldName, boolean isBoolean, boolean isStatic, CodeStyle cs)
fieldName
- the name of the propertyisBoolean
- true if the property is of boolean typeisStatic
- true if the property is staticcs
- the CodeSyle to use@NonNull public static String computeSetterName(CharSequence fieldName, boolean isStatic, CodeStyle cs)
fieldName
- the name of the propertyisStatic
- true if the property is staticcs
- the CodeSyle to useBuilt on June 4 2024. | Copyright © 2017-2024 Apache Software Foundation. All Rights Reserved.