public class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
MAVEN_PROPS |
static NumCompOp |
nc |
protected static Locale |
numLocale |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static boolean[] |
array(boolean... args)
Make array of boolean.
|
static byte[] |
array(byte... args)
Make array of byte.
|
static char[] |
array(char... args)
Make array of char.
|
static double[] |
array(double... args)
Make array of double.
|
static float[] |
array(float... args)
Make array of float.
|
static int[] |
array(int... args)
Make array of int.
|
static long[] |
array(long... args)
Make array of long.
|
static short[] |
array(short... args)
Make array of short.
|
static String |
arrayAsString(Object val)
Convert an array to String for printout.
|
static String |
arrayContentsAsString(Object val)
Convert an array to String for printout.
|
static Object[] |
arrayOfObjects(Object... args)
Make array of Objects.
|
static boolean |
arraysDeepEquals(Object arrayE,
Object arrayV)
Array deep comparison.
|
static Boolean |
asBoolean(Object val)
Coerce object to boolean.
|
static char |
asChar(Object val)
Return object as char.
|
static CharSequence |
asCharSequenceOrNull(Object val)
Convert an object to its String representation,
return CharSequences as is or return null if value is null.
|
static void |
aset(Object arrayObj,
int index,
Object obj)
Set array element.
|
static Number |
asNumber(Object val)
Coerse object to Number.
|
static Object |
asObject(Object val)
Return argument as object.
|
static void |
assertTrue(boolean val)
Assert true value.
|
static String |
asString(Object val)
Convert an object to its String representation.
|
static String |
asStringOrEmpty(Object val)
Convert an object to its String representation or return empty String if value is null.
|
static String |
asStringOrNull(Object val)
Convert an object to its String representation or return null if value is null.
|
static ASTN |
astnize(Object param,
ParseCtx ctx)
Make AST node of objects (honoring lists).
|
static <T> List<T> |
clist(T... objs)
Make unmodifiableList list of positionals args.
|
static Object |
cloneObjectByClone(Cloneable obj)
Tries to copy a Cloneable object using its clone() method.
|
static String |
coalesce(String... strings)
Return first not null not-empty argument.
|
static String |
concat(String... strs)
Concatenate string arguments.
|
static Object |
copyObjectByCopyConstructor(Object obj)
Tries to copy objects using its copy constructor.
|
static Object |
copySeq(Object seq)
Shallow copy sequence.
|
static Class<?> |
defListClz() |
static boolean |
enumEqual(Enum<?> enumE,
Object obj)
Check if equal to enum according to the name of the enum value.
|
static boolean |
equal(Object objA,
Object objB)
Check if objects are equal using Object.equals().
|
static String |
getExplangCoreVersionStr()
Return explang core jar version.
|
static Class<?>[] |
getMethodParamsClasses(List<?> methodParams,
List<?> typeSpecs)
Get array of classes of method parameters given optional array of argument type specifications.
|
static Set<Object> |
intersectSets(Set<?>... sets)
Compute intersection of sets.
|
static boolean |
isEmpty(String str)
Check if String is empty.
|
static boolean |
isFP(Number num)
Check if the argument is a floating point number.
|
static boolean |
isKnownImmutable(Object obj)
Return true if Object is known to be immutable.
|
protected static boolean |
isLast(List<?> list,
int idx)
Check if index is the last of the list.
|
static boolean |
isRoundNumber(Number val)
Check if Number is equal.
|
static <T> List<T> |
list(T... objs)
Make List of positionals args.
|
static String |
listCtxVars(Compiler.ICtx ctx,
Object vars,
IObjectWriter w)
Print contents details with selected context bindings
if vars is a collection of variable names.
|
static String |
listParseErrors(ASTN exprASTN)
Print list of all parse errors for an AST subtree.
|
static <T,U> Map<T,U> |
map(Object... objs)
Make Map of (key value) pairs of positionals args.
|
static int |
max(int intA,
int intB)
Return maximum of two values.
|
static List<ICompiled> |
newPosArgsList(int num)
Create list of positional arguments.
|
static <T> T |
nvl(T... objects)
return first non-null argument.
|
static boolean |
objequal(Object v1,
Object v2)
Return true if object are equeal as Objects or Numerically.
|
static Number |
parseNumber(String str)
Parse string as Number.
|
static int |
parseRegexpFlag(char c)
Convert character regexp flag to its integer constant.
|
static int |
parseRegexpFlags(String flagsStr)
Parse string of regexp flag characters.
|
static <T> Set<T> |
roset(T... objs)
Make Read-only Set of positionals args.
|
static int |
safeLen(String str) |
static <T> Set<T> |
set(T... objs)
Make Set of positionals args.
|
static Reader |
str2reader(String str)
Make Reader from string content.
|
static Class<?> |
strToClass(String str)
Convert class name to a class object.
|
static Symbol |
symbol(String name)
Make Symbol with given name.
|
static Class<?> |
tspecToClass(Object tspec)
Convert type specification to Class a object it is representing.
|
static Object |
unAstnize(ASTN param)
Strip objects out of an AST node.
|
static Set<Object> |
unionSets(Set<?>... sets)
Make union of Sets.
|
protected static final Locale numLocale
public static final NumCompOp nc
public static final String MAVEN_PROPS
public static int safeLen(String str)
public static Class<?> defListClz()
@SafeVarargs public static <T> List<T> list(T... objs)
@SafeVarargs public static <T> List<T> clist(T... objs)
public static <T,U> Map<T,U> map(Object... objs)
@SafeVarargs public static <T> Set<T> set(T... objs)
@SafeVarargs public static <T> Set<T> roset(T... objs)
public static int max(int intA, int intB)
public static String arrayAsString(Object val)
public static String arrayContentsAsString(Object val)
public static String asString(Object val)
Symbols will be printed as their names, Arrays - using arrayAsString, null as NIL, other objects using their toString() method.
public static CharSequence asCharSequenceOrNull(Object val)
public static String asStringOrNull(Object val)
public static String asStringOrEmpty(Object val)
public static Class<?> tspecToClass(Object tspec) throws ClassNotFoundException
ClassNotFoundException
public static List<ICompiled> newPosArgsList(int num)
public static Object copySeq(Object seq)
Creates new instance of sequence of the same type with the same content. Only Lists and Arrays are currently supported.
public static Class<?> strToClass(String str) throws ClassNotFoundException
java.lang classes do not require full path.
ClassNotFoundException
public static Class<?>[] getMethodParamsClasses(List<?> methodParams, List<?> typeSpecs) throws ClassNotFoundException
ClassNotFoundException
public static ASTN astnize(Object param, ParseCtx ctx)
public static String listCtxVars(Compiler.ICtx ctx, Object vars, IObjectWriter w)
public static String listParseErrors(ASTN exprASTN)
public static Object asObject(Object val)
public static char asChar(Object val)
Character object returned as is, Boolean as 'T' or '\0', Byte as corresponding ASCII character, otherwise ASCII character of numeric value
public static Number parseNumber(String str)
public static Number asNumber(Object val)
FIXME: describe conversion FIXME: make configurable
public static boolean isFP(Number num)
protected static boolean isLast(List<?> list, int idx)
public static void assertTrue(boolean val)
public static int[] array(int... args)
public static char[] array(char... args)
public static double[] array(double... args)
public static float[] array(float... args)
public static boolean[] array(boolean... args)
public static byte[] array(byte... args)
public static short[] array(short... args)
public static long[] array(long... args)
public static boolean arraysDeepEquals(Object arrayE, Object arrayV)
public static boolean isEmpty(String str)
@SafeVarargs public static <T> T nvl(T... objects)
public static boolean isRoundNumber(Number val)
public static boolean equal(Object objA, Object objB)
public static boolean enumEqual(Enum<?> enumE, Object obj)
public static boolean objequal(Object v1, Object v2)
public static Object copyObjectByCopyConstructor(Object obj)
public static Object cloneObjectByClone(Cloneable obj)
public static int parseRegexpFlag(char c)
public static int parseRegexpFlags(String flagsStr)
public static boolean isKnownImmutable(Object obj)
Currently using list of types that known to be Immutable.
public static String getExplangCoreVersionStr()
Copyright © 2022. All rights reserved.