Example usage for java.lang.reflect Modifier STATIC

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

Introduction

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

Prototype

int STATIC

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

Click Source Link

Document

The int value representing the static modifier.

Usage

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

/**
 * @return gets or creates getRevisionNumberForDate(aDate) method
 *///from w w  w  .ja v  a2  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:de.micromata.genome.util.bean.PrivateBeanUtils.java

/**
 * Fetch all non static fields./* www.  j av  a2  s  . c  om*/
 *
 * @param ret the ret
 * @param clz the clz
 * @param bean the bean
 */
public static void fetchAllNonStaticFields(Map<String, Object> ret, Class<?> clz, Object bean) {
    fetchAllFields(ret, clz, bean, 0, Modifier.STATIC);
}

From source file:org.gvnix.addon.jpa.addon.audit.providers.envers.EnversRevisionLogMetadataBuilder.java

/**
 * @return Creates XXXRevision.createList(list,reader) static method
 *//*  w w  w .  j a v a2s. c o m*/
private MethodMetadata createRevisionItemCreateList() {
    // Define method parameter types
    List<AnnotatedJavaType> parameterTypes = helper.toAnnotedJavaType(LIST_OBJECT_ARRAY, AUDIT_READER);

    // 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("list", "reader");

    // Create the method body
    InvocableMemberBodyBuilder body = new InvocableMemberBodyBuilder();
    buildRevisionItemCreateListMethodBody(body, parameterNames);

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(context.getMetadataId(),
            Modifier.PUBLIC + Modifier.STATIC, CREATE_ITEM_LIST_METHOD, context.getRevisonItemListType(),
            parameterTypes, parameterNames, body);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

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

From source file:org.eclipse.emf.teneo.PersistenceOptions.java

/**
 * Returns an array of all String constants.
 * /*w  w w. ja  va2s.co  m*/
 * @return
 */
public static String[] propertyNames() {
    final List<String> names = new ArrayList<String>();
    for (Field field : PersistenceOptions.class.getFields()) {
        try {
            if ((field.getModifiers() & Modifier.STATIC) > 0 & field.getType().equals(String.class)) {
                final String value = (String) field.get(null);
                if (value.startsWith("teneo.")) {
                    names.add(value);
                }
            }
        } catch (IllegalAccessException e) {
        }
    }
    Collections.sort(names);
    return names.toArray(new String[names.size()]);
}

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

/**
 * Create metadata for logger static field.
 * /*from   ww w. j  a  va  2s. c  o  m*/
 * @return a FieldMetadata object
 */
public FieldMetadata getLoggerField() {
    if (loggerFiled == null) {
        JavaSymbolName curName = new JavaSymbolName("LOGGER_BATCH");
        // Check if field exist
        FieldMetadata currentField = governorTypeDetails.getDeclaredField(curName);
        if (currentField != null) {
            if (!currentField.getFieldType().equals(LOGGER_TYPE)) {
                // No compatible field: look for new name
                currentField = null;
                JavaSymbolName newName = curName;
                int i = 1;
                while (governorTypeDetails.getDeclaredField(newName) != null) {
                    newName = new JavaSymbolName(curName.getSymbolName().concat(StringUtils.repeat('_', i)));
                    i++;
                }
                curName = newName;
            }
        }
        if (currentField != null) {
            loggerFiled = currentField;
        } else {
            // Prepare initialized
            // LoggerFactory.getLogger(PetController.class);
            String initializer = String.format("%s.getLogger(%s.class);",
                    helper.getFinalTypeName(LOGGER_FACTORY_TYPE),
                    helper.getFinalTypeName(governorPhysicalTypeMetadata.getType()));

            // Using the FieldMetadataBuilder to create the field
            // definition.
            final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(getId(),
                    Modifier.PUBLIC + Modifier.STATIC, curName, // Field
                    LOGGER_TYPE, initializer); // Field type
            loggerFiled = fieldBuilder.build(); // Build and return a
                                                // FieldMetadata
                                                // instance
        }
    }
    return loggerFiled;
}

From source file:com.facebook.ads.sdk.Ad.java

synchronized /*package*/ static Gson getGson() {
    if (gson != null) {
        return gson;
    } else {//from  ww  w.j a v  a2s .com
        gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.STATIC)
                .excludeFieldsWithModifiers(Modifier.PROTECTED).disableHtmlEscaping().create();
    }
    return gson;
}