BeanGenerator { public void generate() { for (String objectClass : objectClasses) { final JDefinedClass definedClass = createClass(packageName, objectClass); final JDocComment jDocComment = definedClass.javadoc(); jDocComment.add(String.format("Ldaptive generated bean for objectClass '%s'", objectClass)); final ObjectClass oc = schema.getObjectClass(objectClass); final Set<String> attributeNames = getAttributeNames(oc); if (useOperationalAttributes) { attributeNames.addAll( schema.getAttributeTypes().stream().filter( type -> AttributeUsage.DIRECTORY_OPERATION.equals(type.getUsage())).map( AttributeType::getName).collect(Collectors.toList())); } final Map<String, AttributeType> mutators = new TreeMap<>(); for (String name : attributeNames) { final AttributeType type = schema.getAttributeType(name); if (!isNameExcluded(type)) { if (nameMappings.containsKey(type.getName())) { mutators.put(nameMappings.get(type.getName()), type); } else { mutators.put(formatAttributeName(type.getName()), type); } } } final JAnnotationUse entryAnnotation = definedClass.annotate(codeModel.ref(org.ldaptive.beans.Entry.class)); entryAnnotation.param("dn", "dn"); final JAnnotationArrayMember attrArray = entryAnnotation.paramArray("attributes"); createMutators(definedClass, "dn", String.class, false); for (Map.Entry<String, AttributeType> mutator : mutators.entrySet()) { final Class<?> syntaxType = getSyntaxType( mutator.getValue(), schema.getSyntax(mutator.getValue().getSyntaxOID(false))); createMutators(definedClass, mutator.getKey(), syntaxType, !mutator.getValue().isSingleValued()); final JAnnotationUse attrAnnotation = attrArray.annotate(org.ldaptive.beans.Attribute.class); attrAnnotation.param("name", mutator.getValue().getName()); if (!mutator.getKey().equals(mutator.getValue().getName())) { attrAnnotation.param("property", mutator.getKey()); } if (byte[].class.equals(syntaxType)) { attrAnnotation.param("binary", true); } } createHashCode(definedClass); createEquals(definedClass); createToString(definedClass); } } BeanGenerator();  BeanGenerator(final Schema s, final String name, final String[] oc); Schema getSchema(); void setSchema(final Schema s); String getPackageName(); void setPackageName(final String name); String[] getObjectClasses(); void setObjectClasses(final String... oc); boolean isUseOptionalAttributes(); void setUseOptionalAttributes(final boolean b); boolean isUseOperationalAttributes(); void setUseOperationalAttributes(final boolean b); boolean isIncludeSuperiorClasses(); void setIncludeSuperiorClasses(final boolean b); Map<String, Class<?>> getTypeMappings(); void setTypeMappings(final Map<String, Class<?>> m); Map<String, String> getNameMappings(); void setNameMappings(final Map<String, String> m); String[] getExcludedNames(); void setExcludedNames(final String... names); void generate(); void write(); void write(final String path); static void main(final String[] args); static Builder builder();  }
@Test(groups = "beans", dataProvider = "schemas") public void generate(final Schema schema, final String packageName, final String[] objectClasses) throws Exception { final BeanGenerator generator = new BeanGenerator(); generator.setSchema(schema); generator.setObjectClasses(objectClasses); generator.setPackageName(packageName); generator.setUseOperationalAttributes(true); generator.setUseOptionalAttributes(true); generator.setIncludeSuperiorClasses(true); generator.generate(); generator.write("target/generated-test-sources/ldaptive"); }