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.loupefield.addon.LoupefieldMetadata.java

public LoupefieldMetadata(String identifier, JavaType aspectName,
        PhysicalTypeMetadata governorPhysicalTypeMetadata, JavaType entity) {
    super(identifier, aspectName, governorPhysicalTypeMetadata);

    // Helper itd generation
    this.helper = new ItdBuilderHelper(this, governorPhysicalTypeMetadata,
            builder.getImportRegistrationResolver());

    // Adding AUTOWIRED annotation
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(1);
    annotations.add(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED));

    // Creating conversionService_loupe field
    conversionServiceField = getField("conversionService_loupe", null,
            new JavaType("org.springframework.core.convert.ConversionService"), Modifier.PUBLIC, annotations);
    builder.addField(conversionServiceField);

    // Creating entityManagerProvider_loupe field
    annotations = new ArrayList<AnnotationMetadataBuilder>(1);
    annotations.add(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED));

    entityManagerProviderField = getField("entityManagerProvider_loupe", null,
            new JavaType("org.gvnix.web.datatables.util.EntityManagerProvider"), Modifier.PUBLIC, annotations);
    builder.addField(entityManagerProviderField);

    // Adding showOnlyList method
    builder.addMethod(getShowOnlyListMethod(entity));

    // Adding findUsingAjax method
    builder.addMethod(getFindUsingAjaxMethod(entity));

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();/*  w w  w  .  jav  a2s  .c  o m*/
}

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

/**
 * Generate a getter for <code>field</code>
 * /*ww  w  .ja  v a2 s .co m*/
 * @param field field metadata
 * @return
 */
private MethodMetadataBuilder getListInner_getter(FieldMetadata field) {
    // Gets filed name
    String fieldName = field.getFieldName().getSymbolName();

    // Generate method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    bodyBuilder.appendFormalLine(MessageFormat.format("return {0};", new Object[] { fieldName }));

    // Creates Method builder
    MethodMetadataBuilder builder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
            new JavaSymbolName("get".concat(StringUtils.capitalize(fieldName))), field.getFieldType(),
            bodyBuilder);

    return builder;
}

From source file:org.codehaus.griffon.ast.GriffonASTUtils.java

public static void addReadOnlyProperty(ClassNode classNode, String propertyName, ClassNode propertyClass,
        Object value) {//w  w w .j  av  a 2 s . com
    final boolean hasProperty = hasOrInheritsProperty(classNode, propertyName);

    if (!hasProperty) {
        int visibility = Modifier.PRIVATE | Modifier.FINAL;
        Expression initialValue = value != null && !(value instanceof Expression)
                ? initialValue = new ConstantExpression(value)
                : (Expression) value;
        classNode.addField(propertyName, visibility, propertyClass, initialValue);
        addMethod(classNode, new MethodNode("get" + MetaClassHelper.capitalize(propertyName), Modifier.PUBLIC,
                propertyClass, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new ReturnStatement(
                        new ExpressionStatement(new FieldExpression(classNode.getField(propertyName))))));
    }
}

From source file:org.gvnix.flex.FlexScaffoldMetadata.java

private MethodMetadata getRemoveMethod() {
    JavaSymbolName methodName = new JavaSymbolName("remove");

    MethodMetadata method = methodExists(methodName);

    if (method != null) {
        return method;
    }//from w w  w  .j  av a  2 s.  com

    // TODO In Roo 1.2.2 migration the identifier fields are multiple:
    // temporary get first element
    FieldMetadata identifierField = persistenceMemberLocator.getIdentifierFields(entity).get(0);

    List<AnnotatedJavaType> paramTypes = new ArrayList<AnnotatedJavaType>();
    paramTypes.add(new AnnotatedJavaType(identifierField.getFieldType(), new ArrayList<AnnotationMetadata>()));

    List<JavaSymbolName> paramNames = new ArrayList<JavaSymbolName>();
    paramNames.add(new JavaSymbolName(identifierField.getFieldName().getSymbolName()));

    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    if (!identifierField.getFieldType().isPrimitive()) {
        bodyBuilder.appendFormalLine("if (" + identifierField.getFieldName().getSymbolName()
                + " == null) throw new IllegalArgumentException(\"An Identifier is required\");");
    }

    bodyBuilder.appendFormalLine(
            this.entity.getNameIncludingTypeParameters(false, this.builder.getImportRegistrationResolver())
                    + "." + this.entityMetadata.getFindMethod().getMethodName() + "("
                    + identifierField.getFieldName().getSymbolName() + ")."
                    + new JpaCrudAnnotationValues(this.entityMetadata).getRemoveMethod() + "();");

    return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.VOID_PRIMITIVE, paramTypes,
            paramNames, bodyBuilder).build();
}

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

/**
 * @return the getUserName method definition
 *//*from  ww w . jav a2  s .  c o  m*/
private MethodMetadata getUserMethod() {
    // method name
    JavaSymbolName methodName = GET_USER_METHOD;

    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();

    // 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 = new ArrayList<JavaSymbolName>();

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

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

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

From source file:com.adobe.aem.sightly.ide.impl.SightlyBeanFinderImpl.java

/**
 * Recursive methods for adding class & superclasses getters
 * @param members//  w  ww . j  a  v a  2s.c  o  m
 * @param name
 */
private void addMembers(Set<JSONObject> members, String name) throws JSONException {
    ClassInfo bean = beans.get(name);
    for (MethodInfo methodInfo : bean.getMethods()) {
        String mName = methodInfo.getName();
        if (methodInfo.getAccess() == Modifier.PUBLIC) {
            String foundName = null;
            if (mName.startsWith(GETTER_PREFIX) && (mName.length() > GETTER_PREFIX.length())) {
                foundName = mName.substring(GETTER_PREFIX.length());
            } else if (mName.startsWith(IS_PREFIX) && (mName.length() > IS_PREFIX.length())) {
                foundName = mName.substring(IS_PREFIX.length());
            }
            if (foundName != null) {
                StringBuilder builder = new StringBuilder(foundName.substring(0, 1).toLowerCase())
                        .append(foundName.substring(1));
                JSONObject object = new JSONObject();
                object.put(KEY_METHOD_NAME, builder.toString());
                object.put(KEY_METHOD_DESC, methodInfo.getDescription());
                object.put(KEY_METHOD_SIGN, methodInfo.getSignature());
                members.add(object);
            }
        }
    }
    String superClass = bean.getSuperClassName();
    if ((superClass != null) && (!superClass.equals(topClass)) && (beans.get(superClass) != null)) {
        addMembers(members, bean.getSuperClassName());
    }
}

From source file:org.mule.module.extension.internal.util.IntrospectionUtils.java

public static Collection<Method> getOperationMethods(Class<?> declaringClass) {
    return getAllMethods(declaringClass, withAnnotation(org.mule.extension.annotations.Operation.class),
            withModifier(Modifier.PUBLIC));
}

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

/**
 * @return the getOnUpdate method definition
 *///from w w w . j a  v a2 s .c o  m
private MethodMetadata getOnUpdateMethod() {
    // method name
    JavaSymbolName methodName = ON_UPDATE_METHOD;

    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
    parameterTypes.add(new AnnotatedJavaType(entity));

    // 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>();
    annotations.add(new AnnotationMetadataBuilder(JPA_PRE_UPDATE));

    // 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(entityParamName);

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

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

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

From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderUserAuthorityMetadata.java

/**
 * Gets <code>hasCode</code> method. <br>
 * // ww  w . j a v a 2 s.  co m
 * @return
 */
private MethodMetadata getHashCodeMethod() {
    // 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(HASH_CODE_METHOD, 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();
    buildHashCodeMethodBody(bodyBuilder);

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

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