protected void printGetValueClassMethod() {
   iprint("@Override%n");
   iprint(
       "public Class<%1$s> getValueClass() {%n",
       TypeMirrorUtil.boxIfPrimitive(domainMeta.getValueType(), env));
   iprint(
       "    return %1$s.class;%n", TypeMirrorUtil.boxIfPrimitive(domainMeta.getValueType(), env));
   iprint("}%n");
   print("%n");
 }
 protected void printNewDomainMethod() {
   iprint("@Override%n");
   iprint(
       "public %1$s newDomain(%2$s value) {%n",
       typeName, TypeMirrorUtil.boxIfPrimitive(domainMeta.getValueType(), env));
   if (domainMeta.providesConstructor()) {
     if (domainMeta.getWrapperType().getWrappedType().isPrimitive()) {
       iprint(
           "    return new %1$s(%2$s.unbox(value));%n",
           typeName, BoxedPrimitiveUtil.class.getName());
     } else {
       iprint("    return new %1$s(value);%n", typeName);
     }
   } else {
     if (domainMeta.getWrapperType().getWrappedType().isPrimitive()) {
       iprint(
           "    return %1$s.%2$s(%3$s.unbox(value));%n",
           domainMeta.getTypeElement().getQualifiedName(),
           domainMeta.getFactoryMethod(),
           BoxedPrimitiveUtil.class.getName());
     } else {
       iprint(
           "    return %1$s.%2$s(value);%n",
           domainMeta.getTypeElement().getQualifiedName(), domainMeta.getFactoryMethod());
     }
   }
   iprint("}%n");
   print("%n");
 }
 protected void printGetDomainClassMethod() {
   if (domainMeta.isParametarized()) {
     iprint("@SuppressWarnings(\"unchecked\")%n");
   }
   iprint("@Override%n");
   iprint("public Class<%1$s> getDomainClass() {%n", typeName);
   if (domainMeta.isParametarized()) {
     iprint("    Class<?> clazz = %1$s.class;%n", domainMeta.getTypeElement().getQualifiedName());
     iprint("    return (Class<%1$s>) clazz;%n", typeName);
   } else {
     iprint("    return %1$s.class;%n", domainMeta.getTypeElement().getQualifiedName());
   }
   iprint("}%n");
   print("%n");
 }
 protected void printClass() {
   if (typeElement.getTypeParameters().isEmpty()) {
     iprint("/** */%n");
   } else {
     iprint("/**%n");
     for (TypeParameterElement typeParam : typeElement.getTypeParameters()) {
       iprint(" * @param <%1$s> %1$s%n", typeParam.getSimpleName());
     }
     iprint(" */%n");
   }
   printGenerated();
   iprint(
       "public final class %1$s implements %2$s<%3$s, %4$s> {%n",
       simpleMetaTypeName,
       DomainType.class.getName(),
       TypeMirrorUtil.boxIfPrimitive(domainMeta.getValueType(), env),
       typeName);
   print("%n");
   indent();
   printValidateVersionStaticInitializer();
   printFields();
   printConstructors();
   printMethods();
   unindent();
   unindent();
   iprint("}%n");
 }
 protected void printFields() {
   if (domainMeta.isParametarized()) {
     iprint("@SuppressWarnings(\"rawtypes\")%n");
   }
   iprint("private static final %1$s singleton = new %1$s();%n", simpleName);
   print("%n");
 }
 public DomainTypeGenerator(
     ProcessingEnvironment env, TypeElement domainElement, DomainMeta domainMeta)
     throws IOException {
   super(env, domainElement, null, null, Constants.METATYPE_PREFIX, "");
   assertNotNull(domainMeta);
   this.domainMeta = domainMeta;
   this.typeName = TypeMirrorUtil.getTypeName(domainMeta.getType(), env);
   this.metaTypeName = MetaUtil.getMetaTypeName(typeName);
   this.simpleMetaTypeName = MetaUtil.getSimpleMetaTypeName(typeName);
   this.typeParamDecl = makeTypeParamDecl(typeName);
 }
 protected void printGetWrapperMethod() {
   iprint("@Override%n");
   iprint(
       "public %1$s<%2$s, %3$s> getWrapper(%3$s domain) {%n",
       DomainWrapper.class.getName(),
       TypeMirrorUtil.boxIfPrimitive(domainMeta.getValueType(), env),
       typeName);
   iprint("    return new Wrapper%1$s(domain);%n", typeParamDecl);
   iprint("}%n");
   print("%n");
 }
 protected void printGetSingletonInternalMethod() {
   iprint("/**%n");
   iprint(" * @return the singleton%n");
   iprint(" */%n");
   if (domainMeta.isParametarized()) {
     iprint("@SuppressWarnings(\"unchecked\")%n");
     iprint(
         "public static %1$s %2$s getSingletonInternal() {%n", typeParamDecl, simpleMetaTypeName);
     iprint("    return (%1$s) singleton;%n", simpleMetaTypeName);
   } else {
     iprint("public static %1$s getSingletonInternal() {%n", simpleMetaTypeName);
     iprint("    return singleton;%n");
   }
   iprint("}%n");
   print("%n");
 }