Class JclUtils


  • public class JclUtils
    extends Object
    This class has some important utility methods commonly required when using JCL
    Author:
    Kamran
    • Constructor Detail

      • JclUtils

        public JclUtils()
    • Method Detail

      • toCastable

        public static Object toCastable​(Object object,
                                        Class<?> clazz)
        Casts the object ref to the passed interface class ref. It actually returns a dynamic proxy for the passed object
        Parameters:
        object -
        clazz -
        Returns:
        castable
      • toCastable

        public static Object toCastable​(Object object,
                                        Class<?>[] clazz)
        Casts the object ref to the passed interface class ref. It actually returns a dynamic proxy for the passed object
        Parameters:
        object -
        clazz - []
        Returns:
        castable
      • toCastable

        public static Object toCastable​(Object object,
                                        Class<?> clazz,
                                        ClassLoader cl)
        Casts the object ref to the passed interface class ref
        Parameters:
        object -
        clazz -
        cl -
        Returns:
        castable
      • toCastable

        public static Object toCastable​(Object object,
                                        Class<?>[] clazz,
                                        ClassLoader cl)
        Casts the object ref to the passed interface class ref
        Parameters:
        object -
        clazz - []
        cl -
        Returns:
        castable
      • cast

        public static <T> T cast​(Object object,
                                 Class<T> clazz)
        Casts the object ref to the passed interface class ref and returns it
        Parameters:
        object -
        clazz -
        Returns:
        T reference
      • cast

        public static <T> T cast​(Object object,
                                 Class<T> clazz,
                                 ClassLoader cl)
        Casts the object ref to the passed interface class ref and returns it
        Parameters:
        object -
        clazz -
        cl -
        Returns:
        T reference
      • clone

        @Deprecated
        public static Object clone​(Object original)
        Deprecated.
        As of release 2.0, replaced by deepClone(Object original)
        Deep clones the Serializable objects in the current classloader. This method is slow and uses Object streams to clone Serializable objects. This method is now deprecated because of its inefficiency and the limitation to clone Serializable objects only. The use of deepClone or shallowClone is now recommended
        Parameters:
        original -
        Returns:
        clone
      • deepClone

        public static Object deepClone​(Object original)
        Deep clones any object
        Parameters:
        original -
        Returns:
        clone
      • shallowClone

        public static Object shallowClone​(Object original)
        Shallow clones any object
        Parameters:
        original -
        Returns:
        clone