Class CopyField

java.lang.Object
org.datanucleus.enhancer.ClassMethod
org.datanucleus.enhancer.methods.CopyField

public class CopyField extends ClassMethod
Method to generate the method "dnCopyField" using ASM.
 protected final void dnCopyField(Answer obj, int index)
 {
     switch (index)
     {
         case 0:
             question = obj.question;
             break;
         default:
             throw new IllegalArgumentException("out of field index :" + index);
     }
 }
 
or with superclass
 protected final void dnCopyField(ComplexAnswer obj, int index)
 {
     switch (index - dnInheritedFieldCount)
     {
         case 0:
             param1 = obj.param1;
             break;
         case 1:
             param2 = obj.param2;
             break;
         default:
             super.dnCopyField(obj, index);
     }
 }
 
and also with minor variations if the class has no fields
  • Constructor Details

    • CopyField

      public CopyField(ClassEnhancer enhancer, String name, int access, Object returnType, Object[] argTypes, String[] argNames)
      Constructor.
      Parameters:
      enhancer - ClassEnhancer
      name - Name of method
      access - Access type
      returnType - Return type
      argTypes - Argument types
      argNames - Argument names
  • Method Details

    • getInstance

      public static CopyField getInstance(ClassEnhancer enhancer)
    • execute

      public void execute()
      Method to add the contents of the class method.
      Specified by:
      execute in class ClassMethod