public static String toSetter(String fieldName) { return toMethod(SETTER_PREFIX, fieldName); }
public static String toIsGetter(String fieldName) { return toMethod(GETTER_IS_PREFIX, fieldName) + "()"; }
public static String toGetter(String fieldName) { return toMethod(GETTER_PREFIX, fieldName) + "()"; }
public static String toField(String fieldName) { String[] pathParts = fieldName.split("\\."); String result = ""; for (String path : pathParts) { result += toMethod(path); } if (result.length() < 2) { return result.toLowerCase(); } return result.substring(0, 1).toLowerCase() + result.substring(1); }
String methodName = MethodHelper.toMethod(MethodHelper.SETTER_PREFIX, annotationMethod.getKey().getSimpleName().toString());
public static String toGetterMethod(TypeElement typeElement, String fieldName) { if (typeElement != null && ProcessorUtils.hasMethod(toMethod(MethodHelper.GETTER_IS_PREFIX, fieldName), typeElement)) { return toIsGetter(fieldName); } return toGetter(fieldName); }
public static String toMethod(String prefix, String fieldName) { PathResolver pathResolver = new PathResolver(fieldName); if (pathResolver.isNested()) { int i = 0; String result = ""; while (pathResolver.hasNext()) { if (i > 0) { result += "."; } String path = pathResolver.next(); if (pathResolver.hasNext()) { result += toGetter(path); } else { result += toMethod(prefix, path); } i++; } return result; } return prefix + toMethod(fieldName); }
protected void printCopyNested(PathResolver domainPathResolver, String fullPath, DomainDeclaredType referenceDomainType, ExecutableElement method, FormattedPrintWriter pw, Field field, String dtoName) { DomainDeclaredType instantiableDomain = (DomainDeclaredType)referenceDomainType.getConverter().getInstantiableDomain(); pw.print(referenceDomainType, " " + domainPathResolver.getCurrent() + " = "); if (instantiableDomain.getId(entityResolver) != null) { if (referenceDomainType.getConverter() == null) { processingEnv.getMessager().printMessage(Kind.ERROR, "[ERROR] No converter/configuration for " + referenceDomainType + " was found. Please, define configuration for " + referenceDomainType); } converterProviderPrinter.printObtainConverterFromCache(pw, ConverterTargetType.DTO, referenceDomainType, field, method, true); pw.println(".createDomainInstance(" + dtoName + "." + MethodHelper.toGetter(fullPath + MethodHelper.toMethod(MethodHelper.toField(instantiableDomain.getIdMethod(entityResolver)))) + ");"); } else { pw.println(TransferObjectElementPrinter.RESULT_NAME + "." + MethodHelper.toGetter(domainPathResolver.getCurrent()) + ";"); pw.println("if (" + domainPathResolver.getCurrent() + " == null) {"); pw.print(domainPathResolver.getCurrent() + " = "); // TODO add NPE check converterProviderPrinter.printObtainConverterFromCache(pw, ConverterTargetType.DTO, referenceDomainType, field, method, true); pw.println(".createDomainInstance(null);"); pw.println("}"); } }
protected void printCopy(PathResolver pathResolver, TransferObjectContext context, FormattedPrintWriter pw) { if (context.getConverter() != null) { printCopyByConverter(context, pathResolver, pw); } else if (context.useConverter()) { String converterName = "converter" + MethodHelper.toMethod("", context.getDtoFieldName()); pw.print(converterProviderPrinter.getDtoConverterType(context.getDomainMethodReturnType(), true), " " + converterName + " = "); converterProviderPrinter.printObtainConverterFromCache(pw, ConverterTargetType.DTO, context.getDomainMethodReturnType(), new Field( TransferObjectElementPrinter.DTO_NAME + "." + MethodHelper.toGetter(context.getDtoFieldName()), null), context.getDomainMethod(), true); pw.println(";"); printCopyByLocalConverter(converterName, pathResolver, context.getDomainMethodReturnType(), context.getDtoFieldName(), pw); } else if (!pathResolver.isNested()) { printCopySimple(pathResolver, context, pw); } }
String newFieldName = "new" + MethodHelper.toMethod(context.getDomainFieldPath()); pw.println(context.getDtoFieldType(), " " + newFieldName + " = null;" ); pw.println("if (" + MethodHelper.toGetter(context.getDtoFieldName()) + " != null) {");
fullPath += MethodHelper.toMethod(currentPath);
ExecutableElement domainGetterMethod; if (domainTypeElement.asElement() != null && ProcessorUtils.hasMethod(MethodHelper.toMethod(MethodHelper.GETTER_IS_PREFIX, domainPathResolver.getCurrent()), domainTypeElement.asElement())) { isMethod = true;
String converterName = "converter" + MethodHelper.toMethod("", context.getDtoFieldName()); pw.print(converterProviderPrinter.getDtoConverterType(context.getDomainMethodReturnType(), true), " " + converterName + " = "); converterProviderPrinter.printObtainConverterFromCache(pw, ConverterTargetType.DOMAIN, context.getDomainMethodReturnType(),
protected void printCopyByConverter(TransferObjectContext context, PathResolver domainPathResolver, FormattedPrintWriter pw) { String converterName = "converter" + MethodHelper.toMethod("", context.getDtoFieldName()); pw.print(context.getConverter().getConverterBase(), " " + converterName + " = ");
String converterName = "converter" + MethodHelper.toMethod("", context.getDtoFieldName()); pw.print(", ", getTypeVariableDelegate(delegateCast), ".class)"); } else if (context.useConverter()) { String converterName = "converter" + MethodHelper.toMethod("", context.getDtoFieldName()); pw.print(converterProviderPrinter.getDtoConverterType(context.getDomainMethodReturnType(), true), " " + converterName + " = "); converterProviderPrinter.printObtainConverterFromCache(pw, ConverterTargetType.DOMAIN, context.getDomainMethodReturnType(),