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:edu.umich.flowfence.common.QMDescriptor.java

public static QMDescriptor forMethod(Context context, Method method) {
    Class<?> definingClass = method.getDeclaringClass();
    String methodName = method.getName();
    Class<?>[] paramTypes = method.getParameterTypes();
    if ((method.getModifiers() & Modifier.STATIC) != 0) {
        return forStatic(context, definingClass, methodName, paramTypes);
    } else {/*from ww w. ja  v  a 2s.  com*/
        return forInstance(context, definingClass, methodName, paramTypes);
    }
}

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

public SafeSecurityProviderUserAuthorityMetadata(String identifier, JavaType aspectName,
        PhysicalTypeMetadata governorPhysicalTypeMetadata) {
    super(identifier, aspectName, governorPhysicalTypeMetadata);
    /*Validate.isTrue(isValid(identifier), "Metadata identification string '"
        + identifier + "' does not appear to be a valid");*/

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

    // Adding Fields
    builder.addField(getField("serialVersionUID", "-2443806778851127910L", JavaType.LONG_PRIMITIVE,
            Modifier.PRIVATE + Modifier.STATIC + Modifier.FINAL));

    builder.addField(getField("authority", null, JAVA_TYPE_STRING, Modifier.PRIVATE));

    // User Details
    builder.addField(getField("nif", null, JAVA_TYPE_STRING, Modifier.PRIVATE));
    builder.addField(getField("usrtipo", null, JAVA_TYPE_STRING, Modifier.PRIVATE));
    builder.addField(getField("idgrupo", null, JAVA_TYPE_STRING, Modifier.PUBLIC));
    builder.addField(getField("idrol", null, JAVA_TYPE_STRING, Modifier.PUBLIC));
    builder.addField(getField("idaplicacion", null, JAVA_TYPE_STRING, Modifier.PUBLIC));

    // Creating getters and setters
    builder.addMethod(getGetterMethod("authority", JavaType.STRING));
    builder.addMethod(getSetterMethod("authority", JavaType.STRING));
    builder.addMethod(getGetterMethod("nif", JavaType.STRING));
    builder.addMethod(getSetterMethod("nif", JavaType.STRING));
    builder.addMethod(getGetterMethod("usrtipo", JavaType.STRING));
    builder.addMethod(getSetterMethod("usrtipo", JavaType.STRING));
    builder.addMethod(getGetterMethod("idgrupo", JavaType.STRING));
    builder.addMethod(getSetterMethod("idgrupo", JavaType.STRING));
    builder.addMethod(getGetterMethod("idrol", JavaType.STRING));
    builder.addMethod(getSetterMethod("idrol", JavaType.STRING));
    builder.addMethod(getGetterMethod("idaplicacion", JavaType.STRING));
    builder.addMethod(getSetterMethod("idaplicacion", JavaType.STRING));

    // Creating methods
    builder.addMethod(getHashCodeMethod());
    builder.addMethod(getEqualsMethod());

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();/*  ww w . j  av  a2s.  com*/
}

From source file:com.mollie.api.resource.BaseResource.java

/**
 * Convenience method to copy all public properties from a src object into
 * a dst object of the same type./*from w ww  . jav  a  2  s . c  o m*/
 *
 * @param src Source object to copy properties from
 * @param dst Target object
 */
protected void copyInto(T src, T dst) {
    Field[] fromFields = returnedClass().getDeclaredFields();
    Object value = null;

    try {
        for (Field field : fromFields) {
            int modifiers = field.getModifiers();

            if ((modifiers & Modifier.PUBLIC) == Modifier.PUBLIC
                    && (modifiers & Modifier.FINAL) != Modifier.FINAL
                    && (modifiers & Modifier.STATIC) != Modifier.STATIC) {
                value = field.get(src);
                field.set(dst, value);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.umich.oasis.common.SodaDescriptor.java

public static SodaDescriptor forMethod(Context context, Method method) {
    Class<?> definingClass = method.getDeclaringClass();
    String methodName = method.getName();
    Class<?>[] paramTypes = method.getParameterTypes();
    if ((method.getModifiers() & Modifier.STATIC) != 0) {
        return forStatic(context, definingClass, methodName, paramTypes);
    } else {//from  w w  w. j  a  v a2  s  .  c o m
        return forInstance(context, definingClass, methodName, paramTypes);
    }
}

From source file:de.micromata.genome.db.jpa.genomecore.chronos.JpaJobStore.java

@Override
public void updateJob(final TriggerJobDO job) {
    if (LOG.isDebugEnabled() == true) {
        LOG.debug("updateJob: " + job);
    }/* ww  w  . j a v  a2  s.c  o  m*/
    emfac.runInTrans(new EmgrCallable<Void, DefaultEmgr>() {
        @Override
        public Void call(DefaultEmgr emgr) {
            JpaTriggerJobDO jjob = emgr.selectByPkAttached(JpaTriggerJobDO.class, job.getPk());
            JpaTriggerJobDO toupdate = SchedJpaTypeConverter.toDb(job);
            PrivateBeanUtils.copyInstanceProperties(JpaTriggerJobDO.class, toupdate, jjob, CommonMatchers.and(
                    FieldMatchers.hasNotModifier(Modifier.STATIC),
                    FieldMatchers.fieldName("+*,-createdAt,-createdBy,-updateCounter,-pk,-attributes")));
            emgr.update(jjob);
            return null;
        }
    });
}

From source file:com.zenesis.qx.remote.ProxyMethod.java

/**
 * @param name//from  www .ja va2s.c om
 * @param returnType
 * @param parameters
 */
public ProxyMethod(Method method) {
    super();
    this.method = method;

    Class returnType = method.getReturnType();
    Class keyType = String.class;
    boolean prefetchResult = false;
    boolean cacheResult = false;
    isMap = Map.class.isAssignableFrom(returnType);
    com.zenesis.qx.remote.annotations.Method anno = method
            .getAnnotation(com.zenesis.qx.remote.annotations.Method.class);

    if (returnType.isArray() || Iterable.class.isAssignableFrom(returnType) || isMap) {
        // How to present on the client - only ArrayList by default is wrapped on the client
        Remote.Array array;
        if (returnType.isArray()) {
            returnType = returnType.getComponentType();
            array = Remote.Array.NATIVE;
        } else {
            returnType = Object.class;
            array = Remote.Array.WRAP;
        }

        // Component type
        if (anno != null) {
            if (anno.array() != Remote.Array.DEFAULT)
                array = anno.array();
            if (anno.arrayType() != Object.class)
                returnType = anno.arrayType();
            if (anno.keyType() != Object.class)
                keyType = anno.keyType();
        }
        this.array = array;
        this.arrayType = returnType;
    } else {
        array = null;
        this.arrayType = null;
    }

    if (anno != null) {
        if (method.getParameterTypes().length == 0) {
            prefetchResult = anno.prefetchResult();
            cacheResult = anno.cacheResult() || prefetchResult;
        }
    }

    this.keyType = keyType;
    this.prefetchResult = prefetchResult;
    this.staticMethod = (method.getModifiers() & Modifier.STATIC) != 0;
    if (staticMethod && cacheResult) {
        log.warn("Cannot cacheResult on static method " + method);
        cacheResult = false;
    }
    this.cacheResult = cacheResult;
}

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

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

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

    // Adding Fields
    builder.addField(getField("LOGGER", "Logger.getLogger(ExtLoadWSS4JOutInterceptor.class)",
            new JavaType("org.apache.log4j.Logger"), Modifier.PRIVATE + Modifier.STATIC + Modifier.FINAL));
    builder.addField(getField(TRACEABILITY, null, JAVA_TYPE_STRING, Modifier.PRIVATE));

    // Creating constructors
    builder.addConstructor(getExtLoadWSS4JConst());
    builder.addConstructor(getExtLoadWSS4JConstWithParam());

    // Creating methods
    builder.addMethod(getSetterMethod(TRACEABILITY, JAVA_TYPE_STRING));
    builder.addMethod(getHandleMessageMethod());

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();// w w w.ja  v  a 2  s .  c  o m
}

From source file:pl.burningice.plugins.image.ast.AbstractImageContainerTransformation.java

protected FieldNode getTransientsField(ClassNode node) {
    FieldNode transientFields = node.getDeclaredField("transients");

    if (transientFields != null) {
        return transientFields;
    }/*from   w ww.ja v  a2  s.co  m*/

    transientFields = new FieldNode("transients", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(List.class),
            new ClassNode(node.getClass()), new ListExpression());
    node.addField(transientFields);
    addGetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    addSetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    return transientFields;
}

From source file:pl.burningice.plugins.image.ast.FileImageContainerTransformation.java

public FieldNode getTransientsField(ClassNode node) {
    FieldNode transientFields = node.getDeclaredField("transients");

    if (transientFields != null) {
        return transientFields;
    }// w w w  . j  a  va 2 s  .  c  o  m

    transientFields = new FieldNode("transients", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(List.class),
            new ClassNode(node.getClass()), new ListExpression());
    node.addField(transientFields);
    addGetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    addSetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    return transientFields;
}

From source file:com.flowpowered.cerealization.config.annotated.AnnotatedObjectConfiguration.java

/**
 * Adds an object or a class to be saved or loaded by the configuration. <p> The node path of the object in the configuration is specified as an array (varargs) of strings. Only annotated fields and
 * methods will be used. <p> The individual paths of the fields can be specified with the Setting annotation. If none are specified, the field name is used. <p> A field named "exa" annotated with
 * {@code @Setting({"cd.ef"})} in an object with path "ab" will have its value saved at "ab.cd.ef". If no path is specified in Setting, the path will be "ab.exa". <p> If the target is a class, only
 * static fields and methods will be registered.
 *
 * @param object The object or class to load or save
 * @param path The path at which the object or class should be or is located in the configuration
 *//*from   ww w.  j  a va  2 s .  c  om*/
@SuppressWarnings("unchecked")
public void add(Object object, String... path) {
    if (!objectMembers.containsKey(object)) {
        final Set<Member> members = new HashSet<Member>();
        if (object instanceof Class<?>) {
            members.addAll(
                    ReflectionUtils.getDeclaredFieldsRecur((Class<?>) object, Modifier.STATIC, Setting.class));
            members.addAll(ReflectionUtils.getDeclaredMethodsRecur((Class<?>) object, Modifier.STATIC,
                    Load.class, Save.class));
        } else {
            members.addAll(ReflectionUtils.getDeclaredFieldsRecur(object.getClass(), Setting.class));
            members.addAll(ReflectionUtils.getDeclaredMethodsRecur(object.getClass(), Load.class, Save.class));
        }
        objectMembers.put(object, members);
    }
    if (!objectPaths.containsKey(object)) {
        objectPaths.put(object, path);
    }
}