public class SharedUtil extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
SIZE_PATTERN
RegEx pattern to extract the width/height values.
|
Constructor and Description |
---|
SharedUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addGetParameters(String uri,
String extraParams)
Adds the get parameters to the uri and returns the new uri that contains
the parameters.
|
static String |
camelCaseToHumanFriendly(String camelCaseString)
Converts a camelCaseString to a human friendly format (Camel case
string).
|
static String |
capitalize(String string)
Capitalizes the first character in the given string in a way suitable for
use in code (methods, properties etc)
|
static boolean |
containsDuplicates(Object[] values)
Checks if the given array contains duplicates (according to
Object.equals(Object) . |
static String |
dashSeparatedToCamelCase(String dashSeparated)
Converts a dash ("-") separated string into camelCase.
|
static boolean |
equals(Object o1,
Object o2)
Checks if a and b are equals using
Object.equals(Object) . |
static String |
getDuplicates(Object[] values)
Return duplicate values in the given array in the format
"duplicateValue1, duplicateValue2".
|
static String |
join(String[] parts,
String separator)
Joins the words in the input array together into a single string by
inserting the separator string between each word.
|
static String |
propertyIdToHumanFriendly(Object propertyId)
Converts a property id to a human friendly format.
|
static String[] |
splitCamelCase(String camelCaseString)
Splits a camelCaseString into an array of words with the casing
preserved.
|
static String |
trimTrailingSlashes(String value)
Trims trailing slashes (if any) from a string.
|
static String |
upperCaseUnderscoreToHumanFriendly(String upperCaseUnderscoreString)
Converts an UPPER_CASE_STRING to a human friendly format (Upper Case
String).
|
public static final String SIZE_PATTERN
public static boolean equals(Object o1, Object o2)
Object.equals(Object)
. Handles null
values as well. Does not ensure that objects are of the same type.
Assumes that the first object's equals method handle equals properly.o1
- The first value to compareo2
- The second value to comparepublic static String trimTrailingSlashes(String value)
value
- The string value to be trimmed. Cannot be null.public static String[] splitCamelCase(String camelCaseString)
camelCaseString
- The input string in camelCase formatpublic static String camelCaseToHumanFriendly(String camelCaseString)
In general splits words when the casing changes but also handles special cases such as consecutive upper case characters. Examples:
MyBeanContainer becomes My Bean Container AwesomeURLFactory becomes Awesome URL Factory SomeUriAction becomes Some Uri Action
camelCaseString
- The input string in camelCase formatpublic static String upperCaseUnderscoreToHumanFriendly(String upperCaseUnderscoreString)
Splits words on _
. Examples:
MY_BEAN_CONTAINER becomes My Bean Container AWESOME_URL_FACTORY becomes Awesome Url Factory SOMETHING becomes Something
upperCaseUnderscoreString
- The input string in UPPER_CASE_UNDERSCORE formatpublic static String join(String[] parts, String separator)
parts
- The array of wordsseparator
- The separator string to use between wordspublic static String capitalize(String string)
string
- The string to capitalizepublic static String propertyIdToHumanFriendly(Object propertyId)
propertyId
- The propertyId to formatpublic static String addGetParameters(String uri, String extraParams)
uri
- The uri to which the parameters should be added.extraParams
- One or more parameters in the format "a=b" or "c=d&e=f". An
empty string is allowed but will not modify the url.public static String dashSeparatedToCamelCase(String dashSeparated)
Examples:
foo becomes foo foo-bar becomes fooBar foo--bar becomes fooBar
dashSeparated
- The dash separated string to convertpublic static boolean containsDuplicates(Object[] values)
Object.equals(Object)
.values
- the array to check for duplicatestrue
if the array contains duplicates,
false
otherwisepublic static String getDuplicates(Object[] values)
values
- the values to check for duplicatesCopyright © 2019 Vaadin Ltd. All rights reserved.