BuilderGenerator implements CodeGenerator { @VisibleForTesting static BuilderTemplate templateForType(final GeneratedType type) { final JavaTypeName origName = type.getIdentifier(); final GeneratedTypeBuilder builderTypeBuilder = new CodegenGeneratedTypeBuilder( origName.createSibling(origName.simpleName() + BuilderTemplate.BUILDER_STR)); final GeneratedTOBuilder implTypeBuilder = builderTypeBuilder.addEnclosingTransferObject( origName.simpleName() + "Impl"); implTypeBuilder.addImplementsType(type); return new BuilderTemplate(builderTypeBuilder.build(), type, getKey(type)); }  @Override boolean isAcceptable(final Type type); @Override String generate(final Type type); @Override String getUnitName(final Type type);  }
@Test public void builderTemplateGenerateToEqualsComparingOrderTest() { final EffectiveModelContext context = YangParserTestUtils.parseYangResource( "/test-types.yang"); final List<Type> types = new DefaultBindingGenerator().generateTypes(context); final BuilderTemplate bt = BuilderGenerator.templateForType((GeneratedType) types.get(19)); final List<String> sortedProperties = bt.properties.stream() .sorted(ByTypeMemberComparator.getInstance()) .map(BuilderGeneratedProperty::getName) .collect(Collectors.toList()); assertEquals(List.of( "id16", "id16Def", "id32", "id32Def", "id64", "id64Def", "id8", "id8Def", "idBoolean", "idBooleanDef", "idDecimal64", "idDecimal64Def","idEmpty", "idEmptyDef", "idIdentityref", "idIdentityrefDef", "idLeafref", "idLeafrefDef", "idU16", "idU16Def", "idU32", "idU32Def", "idU64", "idU64Def", "idU8", "idU8Def", "idBinary", "idBinaryDef", "idBits", "idBitsDef", "idGroupLeafString", "idLeafrefContainer1", "idLeafrefContainer1Def", "idString", "idStringDef", "idInstanceIdentifier", "idInstanceIdentifierDef", "idContainer1", "idContainer2", "idEnumeration", "idEnumerationDef", "idGroupContainer", "idList", "idUnion", "idUnionDef"), sortedProperties); }