if (getEntityResolver().isIdMethod(domainMethod)) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Id method can't be ignored. There should be an id method available for merging purposes.", configurationTypeElement.asConfigurationElement()); return; ExecutableElement nestedIdMethod = currentElement.getIdMethod(getEntityResolver()); if (nestedIdMethod == null && getEntityResolver().shouldHaveIdMethod(currentElement)) { if (idMethod == null && getEntityResolver().shouldHaveIdMethod(domainTypeElement)) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Identifier method could not be found in the automatic way. Please specify id method using " + Id.class.getSimpleName() + " annotation or just specify id as a method name.", configurationTypeElement.asConfigurationElement());
} else if (!entityResolver.isImmutable(instantiableDomainTypeElement.asElement())) { ExecutableElement domainGetterMethod = instantiableDomainTypeElement.getGetterMethod(currentPath); if ((domainGetterMethod == null && field != null && !entityResolver.isIdField(field)) || !entityResolver.isIdMethod(domainGetterMethod)) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Setter is not available for the field " + currentPath + " in the class " + instantiableDomainTypeElement.toString(),
@Override public void finish(ConfigurationTypeElement configurationTypeElement) { if (!entityResolver.shouldHaveIdMethod(configurationTypeElement.getInstantiableDomain())) { pw.println("return true;"); } pw.println("}"); pw.println(); } }
protected boolean isIdField(MutableDeclaredType typeElement, String fieldName) { if (typeElement.asElement() != null) { ExecutableElement method = ProcessorUtils.getMethod(fieldName, typeElement.asElement()); if (method != null) { return entityResolver.isIdMethod(method); } } return false; }
} else if (!entityResolver.isImmutable(domainTypeElement.asElement())) { if ((domainGetterMethod == null && field != null && !entityResolver.isIdField(field)) || !entityResolver.isIdMethod(domainGetterMethod)) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Setter is not available for the field " + domainPathResolver.getCurrent() + " in the class " + domainTypeElement.toString(),
protected void printDtoInstancer(FormattedPrintWriter pw, EntityResolver entityResolver, DtoType type) { pw.println(type," " + RESULT + " = new ", type, "();"); if ((type instanceof DtoDeclaredType) && entityResolver.shouldHaveIdMethod((DomainDeclaredType) type.getDomainDefinitionConfiguration().getInstantiableDomain())) { MutableExecutableElement idMethod = ((DtoDeclaredType)type).getIdMethod(entityResolver); pw.println(RESULT + "." + MethodHelper.toSetter(idMethod) + "((", idMethod.asType().getReturnType(), ")id);"); } pw.println("return " + RESULT + ";"); }
if (entityResolver.isIdMethod(context.getDtoMethod())) {
protected void printDomainInstancer(FormattedPrintWriter pw, DomainDeclaredType domainTypeElement) { if (!entityResolver.shouldHaveIdMethod(domainTypeElement)) { pw.println(" return new ", domainTypeElement, "();"); } else { pw.println(domainTypeElement, " " + RESULT_NAME, " = new ", domainTypeElement, "();"); String setterMethod = MethodHelper.toSetter(domainTypeElement.getIdMethod(entityResolver)); if (ProcessorUtils.hasMethod(setterMethod, domainTypeElement.asElement())) { pw.println(RESULT_NAME + "." + MethodHelper.toSetter(domainTypeElement.getIdMethod(entityResolver)) + "((", domainTypeElement.getId(entityResolver), ")" + "id);"); } else { pw.println("if (id != null) {"); pw.println("throw new ", RuntimeException.class, "(\"Unable to define ID for imutable entity. Please define " + setterMethod + " method for ", domainTypeElement, "!\");"); pw.println("}"); } pw.println("return " + RESULT_NAME + ";"); } } }
boolean idMethod = entityResolver.isIdMethod(context.getDtoMethod());
pw.println(); if (entityResolver.shouldHaveIdMethod(configurationTypeElement.getInstantiableDomain())) {
idMethod = configurationElement.getInstantiableDomain().getIdMethod(entityResolver); if (idMethod == null && entityResolver.shouldHaveIdMethod(configurationElement.getInstantiableDomain())) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Unable to find id method for " + configurationElement.toString(), configurationElement.asConfigurationElement()); return;
@Override public void print(TransferObjectContext context) { if (entityResolver.shouldHaveIdMethod(context.getConfigurationTypeElement().getInstantiableDomain())) { return;
domainIdMethod = configurationElement.getInstantiableDomain().getIdMethod(entityResolver); if (domainIdMethod == null && entityResolver.shouldHaveIdMethod(configurationElement.getInstantiableDomain())) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Unable to find id method for " + configurationElement.toString(), configurationElement.asConfigurationElement()); return; if (dtoIdMethod == null && entityResolver.shouldHaveIdMethod(configurationElement.getInstantiableDomain())) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] Unable to find id method for DTO class " + dtoType.getCanonicalName(), configurationElement.asConfigurationElement()); return;