Package org.springframework.roo.classpath.itd

Examples of org.springframework.roo.classpath.itd.InvocableMemberBodyBuilder


    // Decide whether we need to produce the accessor method (see ROO-619
    // for reason we allow a getter for a final field)
    if (annotationValues.isGettersByDefault()
        && !Modifier.isTransient(field.getModifier())
        && !Modifier.isStatic(field.getModifier())) {
      final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
      bodyBuilder.appendFormalLine("return this."
          + field.getFieldName().getSymbolName() + ";");

      return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
          methodName, field.getFieldType(), bodyBuilder);
    }
View Full Code Here


    // final fields as per ROO-36)
    if (annotationValues.isSettersByDefault()
        && !Modifier.isTransient(field.getModifier())
        && !Modifier.isStatic(field.getModifier())
        && !Modifier.isFinal(field.getModifier())) {
      final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
      bodyBuilder.appendFormalLine("this."
          + field.getFieldName().getSymbolName() + " = "
          + field.getFieldName().getSymbolName() + ";");

      return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
          methodName, JavaType.VOID_PRIMITIVE,
View Full Code Here

      return null;
    }
    // Getting return type
    JavaType returnType = method.getReturnType();
    // Generating body
    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    // If return type is not primitive, return null
    if (returnType.isPrimitive()) {
      JavaType baseType = returnType.getBaseType();
      if (baseType.equals(JavaType.BOOLEAN_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return false;");
      } else if (baseType.equals(JavaType.BYTE_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0;");
      } else if (baseType.equals(JavaType.SHORT_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0;");
      } else if (baseType.equals(JavaType.INT_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0;");
      } else if (baseType.equals(JavaType.LONG_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0;");
      } else if (baseType.equals(JavaType.FLOAT_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0;");
      } else if (baseType.equals(JavaType.DOUBLE_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return 0.00;");
      } else if (baseType.equals(JavaType.CHAR_PRIMITIVE)) {
        bodyBuilder.appendFormalLine("return '\0';");
      }
    } else {
      bodyBuilder.appendFormalLine("return null;");
    }
    return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
        returnType, bodyBuilder);

  }
View Full Code Here

                  .getFullyQualifiedPackageName() + ".", "");
    }

    builder.getImportRegistrationResolver().addImport(collectionType);

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine(collectionName + " " + localEnitiesName
        + " = new " + instantiableCollection + "();");
    bodyBuilder.appendFormalLine("for (Key key : " + entityIdsName + ") {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine(simpleCollectionElementTypeName
        + " entity = " + simpleCollectionElementTypeName + ".find"
        + simpleCollectionElementTypeName + "(key.getId());");
    bodyBuilder.appendFormalLine("if (entity != null) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine(localEnitiesName + ".add(entity);");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("this." + entityCollectionName + " = "
        + localEnitiesName + ";");
    bodyBuilder.appendFormalLine("return " + localEnitiesName + ";");

    return bodyBuilder;
  }
View Full Code Here

        LIST, ARRAY_LIST);

    final String identifierMethodName = getIdentifierMethodName(field)
        .getSymbolName();

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine(collectionName + " " + localEnitiesName
        + " = new " + instantiableCollection + "();");
    bodyBuilder
        .appendFormalLine("List<Long> longIds = new ArrayList<Long>();");
    bodyBuilder.appendFormalLine("for (Key key : " + entityIdsName + ") {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("if (!longIds.contains(key.getId())) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("longIds.add(key.getId());");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("for ("
        + collectionElementType.getSimpleTypeName() + " entity : "
        + entityCollectionName + ") {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("if (!longIds.contains(entity."
        + identifierMethodName + "())) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("longIds.add(entity."
        + identifierMethodName + "());");
    bodyBuilder.appendFormalLine(entityIdsName
        + ".add(KeyFactory.createKey("
        + collectionElementType.getSimpleTypeName()
        + ".class.getName(), entity." + identifierMethodName + "()));");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine(localEnitiesName + ".add(entity);");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("this." + entityCollectionName + " = "
        + localEnitiesName + ";");

    return bodyBuilder;
  }
View Full Code Here

            }
        }

        // We declared the field in this ITD, so produce a public accessor for
        // it
        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
        bodyBuilder.appendFormalLine("return this."
                + idField.getFieldName().getSymbolName() + ";");

        return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
                requiredAccessorName, idField.getFieldType(), bodyBuilder);
    }
View Full Code Here

                        requiredMutatorName.getSymbolName() + "_");
            }
        }

        // We declared the field in this ITD, so produce a public mutator for it
        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
        bodyBuilder.appendFormalLine("this."
                + idField.getFieldName().getSymbolName() + " = id;");

        return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
                requiredMutatorName, JavaType.VOID_PRIMITIVE,
                AnnotatedJavaType.convertFromJavaTypes(parameterTypes),
View Full Code Here

        hiddenIdFieldName);
  }

  private InvocableMemberBodyBuilder getInterfaceMethodBody(
      JavaType returnType) {
    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine("// Interface Implementation");
    bodyBuilder.appendFormalLine("return 0;");
    return bodyBuilder;
  }
View Full Code Here

        .getSimpleTypeName();

    final String identifierMethodName = getIdentifierMethodName(field)
        .getSymbolName();

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder
        .appendFormalLine("if (this." + entityIdName + " != null) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("if (this." + entityName
        + " == null || this." + entityName + "." + identifierMethodName
        + "() != this." + entityIdName + ") {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("this." + entityName + " = "
        + simpleFieldTypeName + ".find" + simpleFieldTypeName
        + "(this." + entityIdName + ");");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("} else {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("this." + entityName + " = null;");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("return this." + entityName + ";");

    return bodyBuilder;
  }
View Full Code Here

    final String entityName = field.getFieldName().getSymbolName();
    final String entityIdName = hiddenIdFieldName.getSymbolName();
    final String identifierMethodName = getIdentifierMethodName(field)
        .getSymbolName();

    final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine("if (" + entityName + " != null) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("if (" + entityName + "."
        + identifierMethodName + " () == null) {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine(entityName + ".persist();");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("this." + entityIdName + " = "
        + entityName + "." + identifierMethodName + "();");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("} else {");
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine("this." + entityIdName + " = null;");
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");
    bodyBuilder.appendFormalLine("this." + entityName + " = " + entityName
        + ";");

    return bodyBuilder;
  }
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.itd.InvocableMemberBodyBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.