Example usage for java.lang.reflect Modifier PUBLIC

List of usage examples for java.lang.reflect Modifier PUBLIC

Introduction

In this page you can find the example usage for java.lang.reflect Modifier PUBLIC.

Prototype

int PUBLIC

To view the source code for java.lang.reflect Modifier PUBLIC.

Click Source Link

Document

The int value representing the public modifier.

Usage

From source file:org.gvnix.addon.web.mvc.addon.batch.WebJpaBatchMetadata.java

/**
 * Return method <code>update</code>
 * //from   www.  j ava 2  s. c o m
 * @return
 */
private MethodMetadata getUpdateMethod() {
    // method name
    JavaSymbolName methodName = UPDATE_METHOD;

    // Define method parameter types
    final List<AnnotatedJavaType> parameterTypes = Arrays.asList(
            new AnnotatedJavaType(listOfEntityType,
                    Arrays.asList(AnnotationMetadataBuilder.getInstance(SpringJavaType.REQUEST_BODY),
                            AnnotationMetadataBuilder.getInstance(Jsr303JavaType.VALID))),
            AnnotatedJavaType.convertFromJavaType(SpringJavaType.BINDING_RESULT),
            AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_REQUEST));

    // Check if a method exist in type
    final MethodMetadata method = methodExists(methodName, parameterTypes);

    if (method != null) {
        // If it already exists, just return the method
        return method;
    }

    // Define method annotations
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // @RequestMapping
    AnnotationMetadataBuilder requestMappingAnnotation = helper.getRequestMappingAnnotation(null, "PUT",
            APP_JSON, APP_JSON, null, "Accept=application/json");
    annotations.add(requestMappingAnnotation);
    // @ResponseBody
    AnnotationMetadataBuilder responseBodyAnnotation = new AnnotationMetadataBuilder();
    responseBodyAnnotation.setAnnotationType(SpringJavaType.RESPONSE_BODY);
    annotations.add(responseBodyAnnotation);

    // Define method throws types (none in this case)
    List<JavaType> throwsTypes = new ArrayList<JavaType>();

    // Define method parameter names (none in this case)
    List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
    parameterNames.add(listOfEntityName);
    parameterNames.add(BINDING_RESULT_NAME);
    parameterNames.add(REQUEST_NAME);

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    buildUpdateMethod(bodyBuilder);

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
            jsonResponseList, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    return methodBuilder.build(); // Build and return a MethodMetadata
    // instance
}

From source file:org.gvnix.addon.geo.addon.GvNIXGeoConversionServiceMetadata.java

/**
 * Gets <code>getStringToMultiLineStringConverter</code> method. <br>
 * // w  w w.  j  a v  a2s . co  m
 * @return
 */
private MethodMetadata getStringToMultiLineStringConverterMethod() {
    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();

    // Check if a method with the same signature already exists in the
    // target type
    final MethodMetadata method = methodExists(STR_TO_MULTSTR_MET, parameterTypes);
    if (method != null) {
        // If it already exists, just return the method and omit its
        // generation via the ITD
        return method;
    }

    // Define method annotations
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // Define method throws types
    List<JavaType> throwsTypes = new ArrayList<JavaType>();

    // Define method parameter names
    List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    buildGetStringToMultiLineStringConverterMethodBody(bodyBuilder);

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
            STR_TO_MULTSTR_MET, CONV_STR_MULTSTR, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    return methodBuilder.build(); // Build and return a MethodMetadata
    // instance
}

From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java

/**
 * Return method to obtain JSon forms to create or update, depending if the
 * parameter {@code isCreateJsonForm} is true or false.
 * /*from  www  . j av  a 2  s.  c  o m*/
 * @param isCreateJsonForm true to return the method to obtain the create
 *        JSon form, false to obtain the update one.
 * @return
 */
private MethodMetadata getJsonFormsMethod(boolean isCreateJsonForm) {

    // method name
    JavaSymbolName methodName = UPDATE_JSON_FORMS_METHOD;
    if (isCreateJsonForm) {
        methodName = CREATE_JSON_FORM_METHOD;
    }

    // Define method parameter types
    final List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
    if (!isCreateJsonForm) {
        parameterTypes.add(helper.createRequestParam(entityIdArrayType, "id", null, null));
    }
    parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_REQUEST));
    parameterTypes.add(AnnotatedJavaType.convertFromJavaType(HTTP_SERVLET_RESPONSE));
    parameterTypes.add(AnnotatedJavaType.convertFromJavaType(MODEL));

    // Check if a method exist in type
    final MethodMetadata method = methodExists(methodName, parameterTypes);

    if (method != null) {
        // If it already exists, just return the method
        return method;
    }

    // Define method annotations
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // @RequestMapping
    String requestMappingValue = "/datatables/updateforms";
    if (isCreateJsonForm) {
        requestMappingValue = "/datatables/createform";
    }
    AnnotationMetadataBuilder requestMappingAnnotation = helper.getRequestMappingAnnotation(requestMappingValue,
            null, null, APPLICATION_JSON, null, ACCEPT_APPLICATION_JSON);
    annotations.add(requestMappingAnnotation);
    // @ResponseBody
    AnnotationMetadataBuilder responseBodyAnnotation = new AnnotationMetadataBuilder();
    responseBodyAnnotation.setAnnotationType(SpringJavaType.RESPONSE_BODY);
    annotations.add(responseBodyAnnotation);

    // Define method throws types (none in this case)
    List<JavaType> throwsTypes = new ArrayList<JavaType>();
    throwsTypes.add(SERVLET_EXCEPTION);
    throwsTypes.add(IO_EXCEPTION);

    // Define method parameter names (none in this case)
    List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
    if (!isCreateJsonForm) {
        parameterNames.add(IDS_PARAM_NAME);
    }
    parameterNames.add(REQUEST_PARAM_NAME);
    parameterNames.add(RESPONSE_PARAM_NAME);
    parameterNames.add(UI_MODEL);

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    if (isCreateJsonForm) {
        buildCreateJsonFormMethodBody(bodyBuilder);
    } else {
        buildUpdateJsonFormsMethodBody(bodyBuilder);
    }

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
            LIST_MAP_STRING_STRING, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    return methodBuilder.build(); // Build and return a MethodMetadata
    // instance
}

From source file:org.apache.axis2.util.Utils.java

/**
 * Create a service object for a given service. The method first looks for
 * the {@link Constants#SERVICE_OBJECT_SUPPLIER} service parameter and if
 * this parameter is present, it will use the specified class to create the
 * service object. If the parameter is not present, it will create an
 * instance of the class specified by the {@link Constants#SERVICE_CLASS}
 * parameter.//from w  ww .  j a  va  2 s. c om
 *
 * @param service
 *            the service
 * @return The service object or <code>null</code> if neither the
 *         {@link Constants#SERVICE_OBJECT_SUPPLIER} nor the
 *         {@link Constants#SERVICE_CLASS} parameter was found on the
 *         service, i.e. if the service doesn't specify how to create a
 *         service object. If the return value is non null, it will always
 *         be a newly created instance.
 * @throws AxisFault
 *             if an error occurred while attempting to instantiate the
 *             service object
 */
public static Object createServiceObject(final AxisService service) throws AxisFault {
    try {
        ClassLoader classLoader = service.getClassLoader();

        // allow alternative definition of makeNewServiceObject
        Parameter serviceObjectSupplierParam = service.getParameter(Constants.SERVICE_OBJECT_SUPPLIER);
        if (serviceObjectSupplierParam != null) {
            final Class<?> serviceObjectSupplierClass = Loader.loadClass(classLoader,
                    ((String) serviceObjectSupplierParam.getValue()).trim());
            if (ServiceObjectSupplier.class.isAssignableFrom(serviceObjectSupplierClass)) {
                ServiceObjectSupplier serviceObjectSupplier = org.apache.axis2.java.security.AccessController
                        .doPrivileged(new PrivilegedExceptionAction<ServiceObjectSupplier>() {
                            public ServiceObjectSupplier run()
                                    throws InstantiationException, IllegalAccessException {
                                return (ServiceObjectSupplier) serviceObjectSupplierClass.newInstance();
                            }
                        });
                return serviceObjectSupplier.getServiceObject(service);
            } else {
                // Prior to r439555 service object suppliers were actually defined by a static method
                // with a given signature defined on an arbitrary class. The ServiceObjectSupplier
                // interface was only introduced by r439555. We still support the old way, but
                // issue a warning inviting the user to provide a proper ServiceObjectSupplier
                // implementation.

                // Find static getServiceObject() method, call it if there
                final Method method = org.apache.axis2.java.security.AccessController
                        .doPrivileged(new PrivilegedExceptionAction<Method>() {
                            public Method run() throws NoSuchMethodException {
                                return serviceObjectSupplierClass.getMethod("getServiceObject",
                                        AxisService.class);
                            }
                        });
                log.warn("The class specified by the " + Constants.SERVICE_OBJECT_SUPPLIER
                        + " property on service " + service.getName() + " does not implement the "
                        + ServiceObjectSupplier.class.getName() + " interface. This is deprecated.");
                return org.apache.axis2.java.security.AccessController
                        .doPrivileged(new PrivilegedExceptionAction<Object>() {
                            public Object run() throws InvocationTargetException, IllegalAccessException,
                                    InstantiationException {
                                return method.invoke(serviceObjectSupplierClass.newInstance(),
                                        new Object[] { service });
                            }
                        });
            }
        } else {
            Parameter serviceClassParam = service.getParameter(Constants.SERVICE_CLASS);
            if (serviceClassParam != null) {
                final Class<?> serviceClass = Loader.loadClass(classLoader,
                        ((String) serviceClassParam.getValue()).trim());
                String className = ((String) serviceClassParam.getValue()).trim();
                Class serviceObjectMaker = Loader.loadClass(classLoader, className);
                if (serviceObjectMaker.getModifiers() != Modifier.PUBLIC) {
                    throw new AxisFault("Service class " + className + " must have public as access Modifier");
                }
                return org.apache.axis2.java.security.AccessController
                        .doPrivileged(new PrivilegedExceptionAction<Object>() {
                            public Object run() throws InstantiationException, IllegalAccessException {
                                return serviceClass.newInstance();
                            }
                        });
            } else {
                return null;
            }
        }
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

@Rpc(description = "Get list of constants (static final fields) for a class")
public Bundle getConstants(
        @RpcParameter(name = "classname", description = "Class to get constants from") String classname)
        throws Exception {
    Bundle result = new Bundle();
    int flags = Modifier.FINAL | Modifier.PUBLIC | Modifier.STATIC;
    Class<?> clazz = Class.forName(classname);
    for (Field field : clazz.getFields()) {
        if ((field.getModifiers() & flags) == flags) {
            Class<?> type = field.getType();
            String name = field.getName();
            if (type == int.class) {
                result.putInt(name, field.getInt(null));
            } else if (type == long.class) {
                result.putLong(name, field.getLong(null));
            } else if (type == double.class) {
                result.putDouble(name, field.getDouble(null));
            } else if (type == char.class) {
                result.putChar(name, field.getChar(null));
            } else if (type instanceof Object) {
                result.putString(name, field.get(null).toString());
            }//w  w  w.  j av  a 2s  . c om
        }
    }
    return result;
}

From source file:org.gvnix.addon.jpa.addon.audit.JpaAuditMetadata.java

/**
 * @return gets or creates findXXX(id, date) method
 *///from   w w w  .ja v  a  2s . co  m
private MethodMetadata getFindFromDateMethod() {
    // method name
    JavaSymbolName methodName = findMethodName;

    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = helper.toAnnotedJavaType(identifier.getFieldType(),
            JdkJavaType.DATE);

    // Check if a method exist in type
    final MethodMetadata method = helper.methodExists(methodName, parameterTypes);
    if (method != null) {
        // If it already exists, just return the method
        return method;
    }

    // Define method annotations (none in this case)
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // Define method throws types (none in this case)
    List<JavaType> throwsTypes = new ArrayList<JavaType>();

    // Define method parameter names (none in this case)
    List<JavaSymbolName> parameterNames = helper.toSymbolName(identifier.getFieldName().getSymbolName(),
            "atDate");

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    revisionLogBuilder.buildBodyFindFromDate(bodyBuilder, parameterNames);

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.STATIC,
            methodName, entity, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    helper.addJavaDocToMethod(methodBuilder,
            "Find a ".concat(entity.getSimpleTypeName()).concat("with values on specified date"), null);

    return methodBuilder.build(); // Build and return a MethodMetadata
}

From source file:org.gvnix.occ.roo.addon.addon.OCCChecksumMetadata.java

/**
 * Locates the checksum accessor method.
 * //w  w w . j av  a  2s . c  om
 * @return the version identifier (may return null if there is no version
 *         field declared in this class)
 */
public MethodMetadata getChecksumAccessor() {
    FieldMetadata checksum = getChecksumField();

    // Compute the name of the accessor that will be produced
    String requiredAccessorName = "get" + StringUtils.capitalize(checksum.getFieldName().getSymbolName());

    // See if the user provided the field, and thus the accessor method
    if (!getId().equals(checksum.getDeclaredByMetadataId())) {
        MethodMetadata method = MemberFindingUtils.getMethod(governorTypeDetails,
                new JavaSymbolName(requiredAccessorName), new ArrayList<JavaType>());
        return method;
    }

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

    return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, new JavaSymbolName(requiredAccessorName),
            checksum.getFieldType(), new ArrayList<AnnotatedJavaType>(), new ArrayList<JavaSymbolName>(),
            bodyBuilder).build();
}

From source file:org.gvnix.addon.jpa.addon.audit.JpaAuditMetadata.java

/**
 * @return gets or creates getRevisionNumberForDate(aDate) method
 *///www .  jav  a 2 s.  c o  m
private MethodMetadata getGetRevisionNumberForDateMethod() {
    // method name
    JavaSymbolName methodName = GET_REV_N_F_DATE_M;

    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = helper.toAnnotedJavaType(JdkJavaType.DATE);

    // Check if a method exist in type
    final MethodMetadata method = helper.methodExists(methodName, parameterTypes);
    if (method != null) {
        // If it already exists, just return the method
        return method;
    }

    // Define method annotations (none in this case)
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // Define method throws types (none in this case)
    List<JavaType> throwsTypes = new ArrayList<JavaType>();

    // Define method parameter names (none in this case)
    List<JavaSymbolName> parameterNames = helper.toSymbolName("aDate");

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    revisionLogBuilder.buildBodyGetRevisionNumberForDate(bodyBuilder, parameterNames);

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.STATIC,
            methodName, JavaType.LONG_OBJECT, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    return methodBuilder.build(); // Build and return a MethodMetadata
}

From source file:org.gvnix.occ.roo.addon.addon.OCCChecksumMetadata.java

/**
 * Locates the checksum mutator//from   w w  w  .  java2 s. co m
 * 
 * @return the version identifier (may return null if there is no version
 *         field declared in this class)
 */
public MethodMetadata getChecksumMutator() {

    // Locate the version field, and compute the name of the mutator that
    // will be produced
    FieldMetadata chekcsum = getChecksumField();
    if (chekcsum == null) {
        // There's no version field, so there certainly won't be a mutator
        // for it
        return null;
    }
    String requiredMutatorName = "set" + StringUtils.capitalize(chekcsum.getFieldName().getSymbolName());

    List<JavaType> paramTypes = new ArrayList<JavaType>();
    paramTypes.add(chekcsum.getFieldType());
    List<JavaSymbolName> paramNames = new ArrayList<JavaSymbolName>();
    paramNames.add(new JavaSymbolName("checksum"));

    // See if the user provided the field, and thus the accessor method
    if (!getId().equals(chekcsum.getDeclaredByMetadataId())) {
        MethodMetadata method = MemberFindingUtils.getMethod(governorTypeDetails,
                new JavaSymbolName(requiredMutatorName), paramTypes);
        return method;
    }

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

    return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, new JavaSymbolName(requiredMutatorName),
            JavaType.VOID_PRIMITIVE, AnnotatedJavaType.convertFromJavaTypes(paramTypes), paramNames,
            bodyBuilder).build();
}

From source file:org.gvnix.web.screen.roo.addon.AbstractPatternMetadata.java

/**
 * Returns the method handling requests of a given gvnixpattern of type
 * tabular/*from w  ww.j  a v  a  2  s.c om*/
 * 
 * @return
 */
protected MethodMetadata getTabularMethod(String patternName) {
    // Specify the desired method name
    JavaSymbolName methodName = new JavaSymbolName("tabular" + patternName);

    // Define method parameter types
    // @RequestParam(value =
    // "fu_org_gvnix_tiendavirtual_domain_ProductoPage", required = false)
    // Integer page,
    // @RequestParam(value =
    // "fu_org_gvnix_tiendavirtual_domain_ProductoPageSize", required =
    // false) Integer pageSize,
    // @RequestParam(value = "gvnixpattern", required = true) String
    // pattern, HttpServletRequest req, Model uiModel)
    List<AnnotatedJavaType> methodParamTypes = new ArrayList<AnnotatedJavaType>();

    methodParamTypes.add(getPageRequestParam().getValue());
    methodParamTypes.add(getPageSizeRequestParam().getValue());
    methodParamTypes.add(getPatternRequestParam(true).getValue());
    Entry<JavaSymbolName, AnnotatedJavaType> modelRequestParam = MODEL_REQUEST_PARAM;
    methodParamTypes.add(modelRequestParam.getValue());
    Entry<JavaSymbolName, AnnotatedJavaType> httpServletRequest = HTTP_SERVLET_REQUEST_PARAM;
    methodParamTypes.add(httpServletRequest.getValue());

    MethodMetadata method = methodExists(methodName, methodParamTypes);
    if (method != null) {
        // If it already exists, just return null and omit its
        // generation via the ITD
        return null;
    }

    // Define method parameter names
    // pattern, uiModel, httpServletRequest
    List<JavaSymbolName> methodParamNames = new ArrayList<JavaSymbolName>();
    Entry<JavaSymbolName, AnnotatedJavaType> patternRequestParam = getPatternRequestParam(false);
    Entry<JavaSymbolName, AnnotatedJavaType> pageRequestParam = getPageRequestParam();
    Entry<JavaSymbolName, AnnotatedJavaType> pageSizeRequestParam = getPageSizeRequestParam();

    methodParamNames.add(pageRequestParam.getKey());
    methodParamNames.add(pageSizeRequestParam.getKey());
    methodParamNames.add(patternRequestParam.getKey());
    methodParamNames.add(modelRequestParam.getKey());
    methodParamNames.add(httpServletRequest.getKey());

    // Create method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    String entityNamePlural = entityTypeDetails.getPlural();

    List<JavaType> typeParams = new ArrayList<JavaType>();
    typeParams.add(entity);

    // Add date validation pattern to model if some date type field exists
    if (!entityDateTypes.isEmpty()) {
        bodyBuilder.appendFormalLine("addDateTimeFormatPatterns(uiModel);");
    }

    bodyBuilder.appendFormalLine("int sizeNo = pageSize == null ? 10 : pageSize.intValue();");
    bodyBuilder.appendFormalLine("float nrOfPages = (float) "
            .concat(entity.getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver()))
            .concat(".")
            .concat(entityTypeDetails.getPersistenceDetails().getCountMethod().getMethodName().concat("()"))
            .concat(" / sizeNo;"));
    bodyBuilder.appendFormalLine(
            "uiModel.addAttribute(\"maxPages\", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));");
    bodyBuilder.appendFormalLine(
            "final int firstResult = page == null || page < 1 ? 0 : (page.intValue() - 1) * sizeNo;");
    JavaType javaUtilList = new JavaType("java.util.List", 0, DataType.TYPE, null, typeParams);
    bodyBuilder.appendFormalLine(javaUtilList
            .getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver()).concat(" ")
            .concat(entityNamePlural.toLowerCase()).concat(" = ")
            .concat(entity.getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver()))
            .concat(".").concat(entityTypeDetails.getPersistenceDetails().getFindEntriesMethod().getMethodName()
                    .concat("(firstResult, sizeNo);")));

    bodyBuilder.appendFormalLine("if (".concat(entityNamePlural.toLowerCase()).concat(
            ".isEmpty() && httpServletRequest.getSession().getAttribute(\"dialogMessage\") == null) {"));
    bodyBuilder.indent();
    bodyBuilder.appendFormalLine(ADD_ATTR.concat(entityNamePlural.toLowerCase()).concat("Tab\", null);"));

    addBodyLinesForDialogMessage(bodyBuilder, DialogType.Info, "message_entitynotfound_problemdescription");

    bodyBuilder.appendFormalLine(
            RETURN_TXT.concat(entityNamePlural.toLowerCase()).concat(CONCAT + GVNIXPATTERN + ");"));
    bodyBuilder.indentRemove();
    bodyBuilder.appendFormalLine("}");

    // May we need to populate some Model Attributes with the data of
    // related entities
    addBodyLinesPopulatingRelatedEntitiesData(bodyBuilder);

    bodyBuilder.appendFormalLine(ADD_ATTR.concat(entityNamePlural.toLowerCase()).concat("Tab\", ")
            .concat(entityNamePlural.toLowerCase()).concat(");"));
    bodyBuilder.appendFormalLine(
            RETURN_TXT.concat(entityNamePlural.toLowerCase()).concat(CONCAT + GVNIXPATTERN + ");"));

    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
            JavaType.STRING, methodParamTypes, methodParamNames, bodyBuilder);

    // Get Method RequestMapping annotation
    List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
    List<AnnotationAttributeValue<? extends Object>> paramValues = new ArrayList<AnnotationAttributeValue<? extends Object>>();
    paramValues.add(getPatternParamRequestMapping(patternName));
    paramValues.add(getFormParamRequestMapping(false));
    paramValues.add(new StringAttributeValue(VALUE_ATTRIBUTE_NAME, "!find"));
    requestMappingAttributes.add(new ArrayAttributeValue<AnnotationAttributeValue<? extends Object>>(
            PARAMS_ATTRIBUTE_NAME, paramValues));
    requestMappingAttributes.add(getMethodRequestMapping(RequestMethod.GET));
    requestMappingAttributes.add(PRODUCES_PARAM_MAPPING);
    AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(RQST_MAP_ANN_TYPE,
            requestMappingAttributes);
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
    annotations.add(requestMapping);
    methodBuilder.setAnnotations(annotations);

    method = methodBuilder.build();
    controllerMethods.add(method);
    return method;
}