Class Cast


  • public final class Cast
    extends Object
    Helper class for the auto cast functionality. Currently, only a single caster is implemented: DoubleToComplexCaster but this can be dynamically extended.
    • Constructor Detail

      • Cast

        private Cast()
    • Method Detail

      • initIfNecessary

        private static void initIfNecessary()
      • register

        private static <F,​T> void register​(Caster<F,​T> caster)
      • cast

        public static <F extends OctaveObject,​T extends OctaveObject> T cast​(Class<T> toClass,
                                                                                   F from)
        Cast and transform the object.
        Type Parameters:
        F - the class type of the object from to be cast.
        T - the target class toClass as a type variable.
        Parameters:
        toClass - the class from
        from - the object to be cast or null.
        Returns:
        The object of type toClass which is by casting from or null for from == null.
      • unsafeGetClass

        private static <F> Class<F> unsafeGetClass​(F from)