private static String stripGet(String getterName, Class<?> type) { if (type == Boolean.TYPE || type == Boolean.class) { if (getterName.startsWith("is") && getterName.length() > 2) { return Character.toLowerCase(getterName.charAt(2)) + getterName.substring(3); } } if (getterName.startsWith("get") && getterName.length() > 3) { return Character.toLowerCase(getterName.charAt(3)) + getterName.substring(4); } return getterName; }
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); } } }