EnumBuilder { public JDefinedClass build() { JPackage _package = determinePackage(); try { definedClass = _package._enum(typeName); } catch (JClassAlreadyExistsException e) { throw new RuntimeException(e.getExistingClass().fullName() + " is already defined in the code model.", e); } addJavadocs(); addInterfaces(); addEnumConstants(); addFields(); addConstructor(); addNameGetter(); addValueGetter(); addToString(); return definedClass; } EnumBuilder(CodeBuilderSettings settings, SmiType type, JCodeModel codeModel);  EnumBuilder(CodeBuilderSettings settings, SmiType type, String typeName, JCodeModel codeModel); JDefinedClass build();  }
@Test public void testMyEnum() throws JClassAlreadyExistsException { SmiCodeNamingStrategy namingStrategy = new StraightNamingStrategy(""); SmiType type = new SmiType(new IdToken(null, "MyEnum"), new SmiModule(new SmiMib(null, null), new IdToken(null, "MyModule")), SmiPrimitiveType.ENUM); type.getModule().getMib().setCodeNamingStrategy(new StraightNamingStrategy(settings.getPackageName())); type.setEnumValues(Arrays.asList(new SmiNamedNumber(new IdToken(null, "enum1"), new BigIntegerToken(1)), new SmiNamedNumber(new IdToken(null, "enum2"), new BigIntegerToken(2)))); JDefinedClass ec = new EnumBuilder(settings, type, codeModel).build(); assertEquals("MyEnum", ec.name()); assertEquals(2, getEnumConstantsByName(ec).size()); }