Class ClassCopier<T>


  • class ClassCopier<T>
    extends java.lang.Object
    ClassCopier helps copying a class. The resulting class works as the original.

    Why would you want to copy a class?

    The problem is described in https://github.com/tpietzsch/none/. The solution suggested there is to copy a specific method of a class, but copying a whole class is easier.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] bytes  
      private java.lang.Class<? extends T> original  
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassCopier​(java.lang.Class<? extends T> original, java.lang.Class<T> interfaceOfOriginal)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private byte[] classToBytes​(java.lang.Class<?> aClass)  
      java.lang.Class<? extends T> copy()  
      • Methods inherited from class java.lang.Object

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

      • original

        private final java.lang.Class<? extends T> original
      • bytes

        private final byte[] bytes
    • Constructor Detail

      • ClassCopier

        public ClassCopier​(java.lang.Class<? extends T> original,
                           java.lang.Class<T> interfaceOfOriginal)
    • Method Detail

      • copy

        public java.lang.Class<? extends T> copy()
      • classToBytes

        private byte[] classToBytes​(java.lang.Class<?> aClass)