public class Util extends Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static Enum |
findInClass(Class clazz,
String e)
Look for methods with return type enum, whose simple class is the first
part of the argument string, look for the enum constant whose name is the
last part of the argument string.
|
static Enum |
getEnumWithValue(Object objectWithEnums)
look for a method returning an enum, call it, if the value isn't null
return it.
|
static boolean |
hasSetterForEnumString(String t,
Object objectWithEnums)
look for a setter ignoring case for a string in the form "enum simple class"."enum name", return true if it is found.
|
static List<Enum> |
listEnums(Class clazz)
look for all methods whose return type is an enum and add all constants
to the result.
|
static <T> T |
setEnum(Enum e,
T objectWithEnums)
Look for a setter for the enum in the object, call it and return the
object.
|
static <T> T |
setEnumsFromString(String inputString,
T objectWithEnums)
parse a string containing enums the form "enum simple class"."enum name"
separated by space, look for the right setter in the Object class and
call the setter.
|
static String |
split(String toSplit,
int index)
Calls
split(java.lang.String, int, boolean) with false. |
static String |
split(String toSplit,
int index,
boolean ignorePatternAfterIndex)
Call
split(java.lang.String, java.lang.String, int, boolean)
with ": ?" as regex. |
static String |
split(String toSplit,
String regex,
int index,
boolean ignorePatternAfterIndex)
split a string on regex and return the requested index, or null.
|
static String |
toString(Enum e)
return "enum simple class"."enum name"
|
static String |
toString(List<Enum> l)
return "[" +
toString(java.lang.Enum) for each enum + "]" |
public static <T> T setEnumsFromString(String inputString, T objectWithEnums)
inputString - space separated inputStrng, containing "enum simple
class"."enum name"objectWithEnums - IllegalArgumentException - when no setter has been called for an
enum stringpublic static boolean hasSetterForEnumString(String t, Object objectWithEnums)
t - objectWithEnums - public static <T> T setEnum(Enum e, T objectWithEnums)
T - e - objectWithEnums - IllegalArgumentException - when no setter has been called for the
enumpublic static Enum getEnumWithValue(Object objectWithEnums)
objectWithEnums - public static List<Enum> listEnums(Class clazz)
clazz - public static Enum findInClass(Class clazz, String e)
clazz - e - string in the form "enum simple class"."enum name"public static String toString(Enum e)
e - public static String toString(List<Enum> l)
toString(java.lang.Enum) for each enum + "]"l - public static String split(String toSplit, int index)
split(java.lang.String, int, boolean) with false.toSplit - index - public static String split(String toSplit, int index, boolean ignorePatternAfterIndex)
split(java.lang.String, java.lang.String, int, boolean)
with ": ?" as regex.toSplit - index - ignorePatternAfterIndex - public static String split(String toSplit, String regex, int index, boolean ignorePatternAfterIndex)
toSplit - index - ignorePatternAfterIndex - when true, occurring ": ?" patterns after
index will be ignored, so the return value will be the rest of the input
string.Copyright © 2018 Fryske Akademy. All rights reserved.