Class StringValueHelper
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.StringValueHelper
-
public class StringValueHelper extends java.lang.ObjectHelps turning an object into a string. Note that this mechanism is different thantoStringas usual for POJOs.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNULL_VALUEprivate static java.util.HashMap<java.lang.Class<?>,IRegisteredStringValueProvider>REGISTERED_PROVIDERS
-
Constructor Summary
Constructors Constructor Description StringValueHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringfirstToLowerCase(java.lang.String string)Turns the first character into a lower case character using the default system locale.static java.lang.StringfirstToLowerCase(java.lang.String string, java.util.Locale locale)Turns the first character into a lower case character using the given locale.static java.lang.StringfirstToUpperCase(java.lang.String string)Turns the first character into an upper case character using the default system locale.static java.lang.StringfirstToUpperCase(java.lang.String string, java.util.Locale locale)Turns the first character into an upper case character using the given locale.static java.lang.StringgetStringValue(java.lang.Object object, IStringValueProvider.StringComparator comparator)Turns the given object into a string usingIStringValueProvider.static java.lang.StringgetStringValue(Collection<?> collection, IStringValueProvider.StringComparator comparator)Turns the given collection into a string.static java.lang.StringgetStringValueInReplacement(java.lang.Object object, IStringValueProvider.StringComparator comparator)Returns the string value in case of value or expression replacements.static IRegisteredStringValueProvidergetStringValueProvider(java.lang.Class<?> objectClass)Returns the registered string value provider.static java.lang.StringlastToLowerCase(java.lang.String string)Turns the last character into a lower case character using the default system locale.static java.lang.StringlastToLowerCase(java.lang.String string, java.util.Locale locale)Turns the last character into a lower case character using the given locale.static java.lang.StringlastToUpperCase(java.lang.String string)Turns the last character into an upper case character using the default system locale.static java.lang.StringlastToUpperCase(java.lang.String string, java.util.Locale locale)Turns the last character into an upper case character using the given locale.static voidregisterStringValueProvider(java.lang.Class<?> objectClass, IRegisteredStringValueProvider provider)Registers a string value provider.static <T> Collection<T>sortCollection(Collection<T> collection, IStringValueProvider.StringComparator comparator)Sorts a given collection according to the string values of the contained elements.
-
-
-
Field Detail
-
NULL_VALUE
public static final java.lang.String NULL_VALUE
- See Also:
- Constant Field Values
-
REGISTERED_PROVIDERS
private static final java.util.HashMap<java.lang.Class<?>,IRegisteredStringValueProvider> REGISTERED_PROVIDERS
-
-
Method Detail
-
firstToUpperCase
public static java.lang.String firstToUpperCase(java.lang.String string)
Turns the first character into an upper case character using the default system locale.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
firstToUpperCase
public static java.lang.String firstToUpperCase(java.lang.String string, java.util.Locale locale)Turns the first character into an upper case character using the given locale.- Parameters:
string- the string to be transformedlocale- the locale to use- Returns:
- the transformed string
-
lastToUpperCase
public static java.lang.String lastToUpperCase(java.lang.String string)
Turns the last character into an upper case character using the default system locale.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
lastToUpperCase
public static java.lang.String lastToUpperCase(java.lang.String string, java.util.Locale locale)Turns the last character into an upper case character using the given locale.- Parameters:
string- the string to be transformedlocale- the locale to use- Returns:
- the transformed string
-
firstToLowerCase
public static java.lang.String firstToLowerCase(java.lang.String string)
Turns the first character into a lower case character using the default system locale.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
firstToLowerCase
public static java.lang.String firstToLowerCase(java.lang.String string, java.util.Locale locale)Turns the first character into a lower case character using the given locale.- Parameters:
string- the string to be transformedlocale- the locale to use- Returns:
- the transformed string
-
lastToLowerCase
public static java.lang.String lastToLowerCase(java.lang.String string)
Turns the last character into a lower case character using the default system locale.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
lastToLowerCase
public static java.lang.String lastToLowerCase(java.lang.String string, java.util.Locale locale)Turns the last character into a lower case character using the given locale.- Parameters:
string- the string to be transformedlocale- the locale to use- Returns:
- the transformed string
-
getStringValueInReplacement
public static java.lang.String getStringValueInReplacement(java.lang.Object object, IStringValueProvider.StringComparator comparator)Returns the string value in case of value or expression replacements. In this situation, further conversions may apply, such as thatIvmlElementsare converted into their actual value rather than returning their name.- Parameters:
object- the object to be turned into a stringcomparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
registerStringValueProvider
public static void registerStringValueProvider(java.lang.Class<?> objectClass, IRegisteredStringValueProvider provider)Registers a string value provider.- Parameters:
objectClass- the class to register the provider forprovider- the provider
-
getStringValueProvider
public static IRegisteredStringValueProvider getStringValueProvider(java.lang.Class<?> objectClass)
Returns the registered string value provider.- Parameters:
objectClass- the class the provider was registered for- Returns:
- the registered provider (or null if none was found)
-
getStringValue
public static java.lang.String getStringValue(java.lang.Object object, IStringValueProvider.StringComparator comparator)Turns the given object into a string usingIStringValueProvider.- Parameters:
object- the object to be turned into a stringcomparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
getStringValue
public static java.lang.String getStringValue(Collection<?> collection, IStringValueProvider.StringComparator comparator)
Turns the given collection into a string.- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returnedcollection- the collection to be turned into a string- Returns:
- the string value
-
sortCollection
public static <T> Collection<T> sortCollection(Collection<T> collection, IStringValueProvider.StringComparator comparator)
Sorts a given collection according to the string values of the contained elements.- Type Parameters:
T- the entry type of the collection- Parameters:
collection- the collection to be sortedcomparator- the comparator to be used for sorting- Returns:
- a sorted collection of the same type or
collectionif nocomparatoris given, orcollectionis null
-
-