Пример #1
0
 public void addMatchingSetters() {
   check(implInterface || !dataTypeIn.isInterface());
   Set<String> usedFields = new HashSet<>();
   if (constructorParams != null) {
     usedFields.addAll(constructorParams);
   }
   if (factoryParams != null) {
     usedFields.addAll(factoryParams);
   }
   for (List<String> list : setters.values()) {
     usedFields.addAll(list);
   }
   for (String fieldName : fields.keySet()) {
     FieldGen fieldGen = fields.get(fieldName);
     Method getter = fieldGen.method;
     if (getter == null) continue;
     if (usedFields.contains(fieldName)) continue;
     String setterName =
         "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
     try {
       Method setter;
       if (implInterface) setter = dataTypeOut.getMethod(setterName, getter.getReturnType());
       else setter = dataTypeIn.getMethod(setterName, getter.getReturnType());
       if (!isPrivate(setter.getModifiers())) {
         addSetter(setter, asList(fieldName));
       }
     } catch (NoSuchMethodException e) {
       throw new RuntimeException(e);
     }
   }
 }
Пример #2
0
  void restoreTransformedClasses(@Nonnull Set<ClassIdentification> previousTransformedClasses) {
    if (!transformedClasses.isEmpty()) {
      Set<ClassIdentification> classesToRestore;

      if (previousTransformedClasses.isEmpty()) {
        classesToRestore = transformedClasses.keySet();
      } else {
        classesToRestore = getTransformedClasses();
        classesToRestore.removeAll(previousTransformedClasses);
      }

      if (!classesToRestore.isEmpty()) {
        restoreAndRemoveTransformedClasses(classesToRestore);
      }
    }
  }
Пример #3
0
  private void restoreDefinition(@Nonnull Class<?> redefinedClass) {
    if (redefinedClassesWithNativeMethods.contains(redefinedClass.getName())) {
      reregisterNativeMethodsForRestoredClass(redefinedClass);
    }

    removeMockedClass(redefinedClass);
  }
Пример #4
0
 public void addRedefinedClassWithNativeMethods(@Nonnull String redefinedClassInternalName) {
   redefinedClassesWithNativeMethods.add(redefinedClassInternalName.replace('/', '.'));
 }