Class CastUtility


  • public final class CastUtility
    extends java.lang.Object
    Author:
    Peter Verhas date Jun 30, 2012
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object cast​(java.lang.Object object, java.lang.Class<?> castTo)
      Convert an object to another object so that the result does have the type castTo.
      static java.lang.Object toObject​(RightValue rightValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • cast

        public static java.lang.Object cast​(java.lang.Object object,
                                            java.lang.Class<?> castTo)
        Convert an object to another object so that the result does have the type castTo.

        This is not a generic solution but does some handy conversion like Long to Integer so that the BASIC programs can easily call Java methods that accept int, float etc.

        Casting is done on best effort. If the class is unknown to the utility then the original object is returned and it is up to the higher level code to recognize the class mis-alignment.

        Parameters:
        object - the object to convert.
        castTo - the class that the result has to belong to.
        Returns:
        the converted object.
      • toObject

        public static java.lang.Object toObject​(RightValue rightValue)