public void addSetter(Method method, List<String> fields) {
   check(implInterface || !dataTypeIn.isInterface());
   checkNotNull(method);
   checkNotNull(fields);
   check(!isPrivate(method.getModifiers()), "Setter cannot be private: %s", method);
   check(method.getGenericParameterTypes().length == fields.size());
   check(!setters.containsKey(method));
   setters.put(method, fields);
 }
 public void setConstructor(Constructor<?> constructor, List<String> fields) {
   check(implInterface || !dataTypeIn.isInterface());
   checkNotNull(constructor);
   checkNotNull(fields);
   check(this.constructor == null, "Constructor is already set: %s", this.constructor);
   check(!isPrivate(constructor.getModifiers()), "Constructor cannot be private: %s", constructor);
   check(constructor.getGenericParameterTypes().length == fields.size());
   this.constructor = constructor;
   this.constructorParams = fields;
 }
 public void setFactory(Method methodFactory, List<String> fields) {
   check(implInterface || !dataTypeIn.isInterface());
   checkNotNull(methodFactory);
   checkNotNull(fields);
   check(this.factory == null, "Factory is already set: %s", this.factory);
   check(!isPrivate(methodFactory.getModifiers()), "Factory cannot be private: %s", methodFactory);
   check(isStatic(methodFactory.getModifiers()), "Factory must be static: %s", methodFactory);
   check(methodFactory.getGenericParameterTypes().length == fields.size());
   this.factory = methodFactory;
   this.factoryParams = fields;
 }
 private Expression callFactory(Map<String, Expression> map, int version) {
   Expression[] param = new Expression[factoryParams.size()];
   int i = 0;
   for (String fieldName : factoryParams) {
     final FieldGen fieldGen = fields.get(fieldName);
     checkNotNull(fieldGen, "Field '%s' is not found in '%s'", fieldName, factory);
     if (fieldGen.hasVersion(version)) {
       param[i++] = map.get(fieldName);
     } else {
       param[i++] = pushDefaultValue(fieldGen.getAsmType());
     }
   }
   return callStatic(factory.getDeclaringClass(), factory.getName(), param);
 }
  private Expression callConstructor(
      Class<?> targetType, final Map<String, Expression> map, int version) {
    Expression[] param;
    if (constructorParams == null) {
      param = new Expression[0];
      return constructor(targetType, param);
    }
    param = new Expression[constructorParams.size()];

    int i = 0;
    for (String fieldName : constructorParams) {
      FieldGen fieldGen = fields.get(fieldName);
      checkNotNull(fieldGen, "Field '%s' is not found in '%s'", fieldName, constructor);
      if (fieldGen.hasVersion(version)) {
        param[i++] = map.get(fieldName);
      } else {
        param[i++] = pushDefaultValue(fieldGen.getAsmType());
      }
    }
    return constructor(targetType, param);
  }