Class Casting


  • public class Casting
    extends Object
    Utility methods for doing casting
    Author:
    Tony Vaagenes
    • Constructor Detail

      • Casting

        public Casting()
    • Method Detail

      • cast

        public static <T> Optional<T> cast​(Class<T> targetClass,
                                           Object instance)
        Returns the casted instance if it is assignment-compatible with targetClass, or empty otherwise.
        See Also:
        Class.isInstance(Object)