|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.util.ObjectTools
public class ObjectTools
| Method Summary | ||
|---|---|---|
static
|
changeArraySize(T[] src,
int newLength)
Returns a new array of the same type as the passed array but with the length of the new array set to newLength. |
|
static
|
changeArraySize(T[] src,
int newLength,
T pad)
Returns a new array of the same type as the passed array but with the length of the new array set to newLength. |
|
static int |
findMatch(Object lookFor,
Object[] list)
Returns the index into list where the first isSame(lookFor, list[i])
returns true. |
|
static int |
findMatch(Object lookFor,
Object[] list,
int offset)
Returns the index into list where the first isSame(lookFor, list[i])
returns true—starting with offset. |
|
static boolean |
isAnySlotEmpty(Object[] obj)
Returns true if the passed parameter is null, points to a zero-length array, or if any slot in that array contains null. |
|
static boolean |
isDifferent(Object a,
Object b)
Compares two references to see if they are "different". |
|
static boolean |
isDifferentArray(Object[] a,
Object[] b)
Compares two arrays to see if they are "different". |
|
static boolean |
isEmpty(Object[] obj)
Returns true if array is either null or has a length of zero. |
|
static boolean |
isEverySlotEmpty(Object[] obj)
Returns true if the passed parameter is null, points to a zero-length array, or if every slot in that array contains null. |
|
static boolean |
isNoSlotEmpty(Object[] obj)
Returns true if the passed array does not have any "empty" (null) slots. |
|
static boolean |
isNotEmpty(Object[] obj)
Returns true if array is not null and has a length greater than zero. |
|
static boolean |
isSame(Object a,
Object b)
Compares two references to see if they are "the same". |
|
static boolean |
isSameArray(Object[] a,
Object[] b)
Compares two arrays to see if they are "the same". |
|
static Object |
paramNullCheck(Object param)
Used as a helper to check passed parameters for prohibited null values in other methods. |
|
static Object |
paramNullCheck(Object param,
String paramName)
Used as a helper to check passed parameters for prohibited null values in other methods. |
|
static String |
printArray(Object[] obj,
String name)
Returns a String with a dump of the contents of the specified array. |
|
static Object[] |
removeFromArray(Object[] src,
Object item)
Removes all occurrences of the specified item from the specified array. |
|
static
|
typeCheck(Object value,
Class<T> targetType)
Checks that the passed value is not null and can be cast into the specified targetType. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isSame(Object a,
Object b)
a - the first Objectb - the second Object
isDifferent(Object, Object)
public static boolean isDifferent(Object a,
Object b)
a - the first Objectb - the second Object
isSame(Object, Object)
public static boolean isSameArray(Object[] a,
Object[] b)
isSame"
a - the first arrayb - the second array
isDifferentArray(Object[], Object[])
public static boolean isDifferentArray(Object[] a,
Object[] b)
isSameArray(Object[], Object[]) to see what is
considered to be "the same", and this method returns the opposite.
public static boolean isEmpty(Object[] obj)
public static boolean isNotEmpty(Object[] obj)
public static boolean isEverySlotEmpty(Object[] obj)
public static boolean isAnySlotEmpty(Object[] obj)
public static boolean isNoSlotEmpty(Object[] obj)
public static <T> T[] changeArraySize(T[] src,
int newLength,
T pad)
throws IllegalArgumentException
src - array to copy from and to sense the type from, must not
be null (but it is OK if it has a zero-length).newLength - the length of the returned array.pad - if needed, this reference is copied into the additional
slots.
IllegalArgumentException - if src is null
or if newLength is negative.
public static <T> T[] changeArraySize(T[] src,
int newLength)
throws IllegalArgumentException
src - array to copy from and to sense the type from, must not
be null (but it is OK if it has a zero-length).newLength - the length of the returned array.
IllegalArgumentException - if src is null
or if newLength is negative.
public static Object[] removeFromArray(Object[] src,
Object item)
throws IllegalArgumentException
src - array to copy from and to sense the type from, must not
be null (but it is OK if it has a zero-length).
This array is never modified by this method.item - the one to match for removal. If null then
all null slots in the array are removed.
IllegalArgumentException - if src is null.
public static int findMatch(Object lookFor,
Object[] list,
int offset)
isSame(lookFor, list[i])
returns true—starting with offset.
Returns -1 if no match is found from the specified offset to
the end of the array.
The list passed in does not need to be sorted as the search
is sequential starting at offset.
public static int findMatch(Object lookFor,
Object[] list)
isSame(lookFor, list[i])
returns true. Returns -1 if not found. The list
passed in does not need to be sorted as the search is sequential
from the beginning.
public static String printArray(Object[] obj,
String name)
obj - the array for format. OK to pass null and OK to
pass a zero-length array (there will be some output).name - the name of the array to use in the output.
public static Object paramNullCheck(Object param,
String paramName)
throws IllegalArgumentException
param - the parameter value to check.paramName - the optional name of the parameter being checked.
If present, paramName is used to enhance the text of the
exception.
IllegalArgumentException - if param is null.
public static Object paramNullCheck(Object param)
throws IllegalArgumentException
param - the parameter value to check.
IllegalArgumentException - if param is null.
public static <T> T typeCheck(Object value,
Class<T> targetType)
throws ClassCastException
value - the value to checktargetType - the type be check against. If null, then
the type Object is assumed.
ClassCastException - if the passed value is null or
if it can't be cast into the specified targetType.
|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||