Package com.storedobject.core
Class Utility
java.lang.Object
com.storedobject.core.Utility
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateBlank date: The local date Jan 1, 1800 is considered blank by the platform for internal purposes.static final longBlank time: The local time Jan 1, 1800 0:00 is considered blank by the platform for internal purposes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TConstruct an instance of an object by creating aConstructorthat matches best with the parameters passed.static <T,O> O[] Copies elements from an iterable to an array using a provided converter function.static MethodGet a method of a class.static <D extends Date>
booleanisEmpty(D dateTime) Check whether the given date/time is empty/blank or not.static booleanisRightAligned(Object value) Is the given value right-aligned?static intGet the size of a sub-list.static StringReturn the stack trace of the current thread at the current line as a string.static StringstackTrace(Throwable error) Return the stack trace of the givenThrowableas a string.static <O> Stream<O> static <O> Stream<O> static <T> Stream<T> Get the stream of a sub-list.
-
Field Details
-
BLANK_TIME
public static final long BLANK_TIMEBlank time: The local time Jan 1, 1800 0:00 is considered blank by the platform for internal purposes.- See Also:
-
BLANK_DATE
Blank date: The local date Jan 1, 1800 is considered blank by the platform for internal purposes.
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
size
Get the size of a sub-list. Index values will be re-adjusted to the valid range automatically to eliminate any exceptions.- Parameters:
list- List from which sub-list to be obtained.startingIndex- Starting index.endingIndex- Ending index.- Returns:
- Size.
-
stream
Get the stream of a sub-list. Index values will be re-adjusted to the valid range automatically to eliminate any exceptions.- Parameters:
list- List from which sub-list to be obtained.startingIndex- Starting index.endingIndex- Ending index.- Returns:
- Stream.
-
isRightAligned
Is the given value right-aligned? (Examples of right-aligned values are numeric values, quantity etc.) The notion of right-alignment depends on the locale. Here, the meaning is as per left-to-right language convention.Note: A null value is considered as not right-aligned.
- Parameters:
value- Value to check. This could beClassof the value too.- Returns:
- True if right-aligned, otherwise false.
-
isEmpty
Check whether the given date/time is empty/blank or not.- Type Parameters:
D- Type of date/timestamp.- Parameters:
dateTime- Date/timestamp to check.- Returns:
- True if empty/blank, otherwise false.
-
stream
-
stream
-
construct
Construct an instance of an object by creating aConstructorthat matches best with the parameters passed.- Type Parameters:
T- The type of object to be created.- Parameters:
objectClass- The class of the object to be created.paramClasses- List of classes of the parameters. (These could be subclasses of the classes of the actual parameter instances).params- Actual parameter instances to be used.- Returns:
- The new instance or
nullif an instance can not be created because no matching constructor is found. - Throws:
LogicRedirected- If the instance is a logic, and it is redirected when instantiated.
-
getMethod
Get a method of a class. If a method is not found, it will look for methods that take superclasses of the parameter.- Parameters:
ofClass- Of class.methodName- Method name.parameter- Method parameter type (Only single parameter is supported).- Returns:
- Method if found, otherwise, null.
-
stackTrace
Return the stack trace of the current thread at the current line as a string. Useful for logging.- Returns:
- Stack trace as a string.
-
stackTrace
-
copyTo
Copies elements from an iterable to an array using a provided converter function.- Type Parameters:
T- Type of elements in the iterable.O- Type of elements in the array.- Parameters:
iterable- The iterable containing elements to be copied.array- The array to copy elements into. Must be of type O[].converter- The function that converts elements from type T to type O.- Returns:
- The array with copied elements. Returns null if either the iterable or the array is null.
-