Class CastUtility

java.lang.Object
com.scriptbasic.utility.CastUtility

public final class CastUtility extends Object
Author:
Peter Verhas date Jun 30, 2012
  • Method Details

    • cast

      public static Object cast(Object object, 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 Object toObject(RightValue rightValue)