public final class Utils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
bytesToObject(byte[] serializedObject)
Deserializes the given byte representation of an object and returns the corresponding object.
|
static java.lang.String |
changeExtension(java.lang.String originalName,
java.lang.String newExtension)
changes extension to new extension
example: x = changeExtension("data.txt", ".java") will assign "data.java"
to x.
|
static void |
copyInto(double[][][] from,
double[][][] to) |
static double[][][] |
copyOf(double[][][] array,
int newLength1,
int newLength2,
int newLength3)
deep copy arrays and cut/pad to size
|
static double[][] |
copyOf(double[][] array,
int newLength1,
int newLength2)
deep copy arrays and cut/pad to size
|
static <T extends java.io.Serializable> |
deepCopy(T object)
Creates a deep copy of a given object.
|
static double[] |
fill(int size,
double value) |
static <T> java.util.List<T> |
flatten(T type,
java.util.Collection<?> collection)
Creates a flat copy of a (deep) collection hierarchy.
|
static java.util.Set<java.lang.reflect.Field> |
getDeclaredFields(java.lang.Class<?> clazz)
Returns all the fields of a given class including the fields of all superclasses.
|
static java.util.Set<java.lang.reflect.Method> |
getDeclaredMethods(java.lang.Class<?> clazz)
Returns all the fields of a given class including the fields of all superclasses.
|
static java.lang.reflect.Field |
getField(java.lang.Class<?> clazz,
java.lang.String fieldName)
Returns the field of a given class also searching for the field in superclasses.
|
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> clazz,
java.lang.String methodName)
Returns the method of a given class also searching for the method in superclasses.
|
static byte[] |
objectToBytes(java.io.Serializable object)
Serializes the given object and returns a byte representation.
|
static double[] |
randomArray(int size,
java.util.Random random,
double min,
double max) |
static void |
randomFill(double[][][] array,
java.util.Random random,
double min,
double max) |
static void |
randomFill(double[][] array,
java.util.Random random,
double min,
double max) |
static void |
randomFill(double[] array,
java.util.Random random,
double min,
double max) |
static java.util.List<java.lang.Double> |
randomList(int size,
java.util.Random random,
double min,
double max) |
static <T extends java.lang.Number> |
sum(java.lang.Iterable<T> iterable) |
public static <T extends java.lang.Number> T sum(java.lang.Iterable<T> iterable)
public static double[][] copyOf(double[][] array,
int newLength1,
int newLength2)
Arrays.copyOf(double[], int)public static double[][][] copyOf(double[][][] array,
int newLength1,
int newLength2,
int newLength3)
Arrays.copyOf(double[], int)public static void copyInto(double[][][] from,
double[][][] to)
public static double[] fill(int size,
double value)
public static double[] randomArray(int size,
java.util.Random random,
double min,
double max)
public static java.util.List<java.lang.Double> randomList(int size,
java.util.Random random,
double min,
double max)
public static void randomFill(double[] array,
java.util.Random random,
double min,
double max)
public static void randomFill(double[][] array,
java.util.Random random,
double min,
double max)
public static void randomFill(double[][][] array,
java.util.Random random,
double min,
double max)
public static java.lang.String changeExtension(java.lang.String originalName,
java.lang.String newExtension)
originalName - newExtension - public static java.lang.reflect.Field getField(java.lang.Class<?> clazz,
java.lang.String fieldName)
throws java.lang.NoSuchFieldException
clazz - fieldName - java.lang.NoSuchFieldExceptionClass.getField(String),
Class.getDeclaredField(String)public static java.lang.reflect.Method getMethod(java.lang.Class<?> clazz,
java.lang.String methodName)
throws java.lang.NoSuchMethodException
clazz - methodName - java.lang.NoSuchFieldExceptionjava.lang.NoSuchMethodExceptionClass.getField(String),
Class.getDeclaredField(String)public static java.util.Set<java.lang.reflect.Field> getDeclaredFields(java.lang.Class<?> clazz)
clazz - Class.getFields(),
Class.getDeclaredFields()public static java.util.Set<java.lang.reflect.Method> getDeclaredMethods(java.lang.Class<?> clazz)
clazz - Class.getFields(),
Class.getDeclaredFields()public static byte[] objectToBytes(java.io.Serializable object)
object - public static java.lang.Object bytesToObject(byte[] serializedObject)
serializedObject - public static <T extends java.io.Serializable> T deepCopy(T object)
T - object - public static <T> java.util.List<T> flatten(T type,
java.util.Collection<?> collection)