Esempio n. 1
0
 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");
 }
Esempio n. 2
0
 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");
 }