Package org.polyfrost.oneconfig.utils.v1
Class WrappingUtils
java.lang.Object
org.polyfrost.oneconfig.utils.v1.WrappingUtils
Various utilities for wrapping and unboxing of arrays and lists
see ArrayCastUtils for more info
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?> getUnwrapped(Class<?> cls) Return the primitive class for the given wrapped classstatic Class<?> getWrapped(Class<?> cls) Return the wrapped class for the given primitive classstatic booleanreturns true if the object is a primitive wrapperstatic booleanisSimpleClass(Class<?> c) static booleanreturns true if
- the object is a primitive wrapper
- the object is a CharSequencestatic <T> TMethod that will attempt to get around the quirks of casting involving primitives in java
This method will do the following
-
Constructor Details
-
WrappingUtils
public WrappingUtils()
-
-
Method Details
-
getWrapped
Return the wrapped class for the given primitive classIf this class is not a primitive it will return the same class
-
getUnwrapped
Return the primitive class for the given wrapped classIf this class is not a wrapper it will return the same class
-
richCast
Method that will attempt to get around the quirks of casting involving primitives in java
This method will do the followingThese actions are effectively chained where applicable so a
List<Integer>can become a long[] if needed- Convert Number classes to the target type such as Float into Double
- Turn Object[] arrays into their actual types by inspecting the type of the first element
- Turn
Collection<?>into their array counterparts - unbox boxed arrays such as Integer[] into int[]
- cast array content to the given type if possible
- convert between common primitve array types such as int[] into long[]
-
isSimpleObject
returns true if
- the object is a primitive wrapper
- the object is a CharSequence -
isSimpleClass
-
isPrimitiveWrapper
returns true if the object is a primitive wrapper
-