All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ninja.cero.sqltemplate.core.util.BeanFields Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package ninja.cero.sqltemplate.core.util;

import java.lang.reflect.Field;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * The fields cache of the value object classes.
 */
public class BeanFields {
    /** The cache of the fields of classes. */
    protected static final ConcurrentMap, Field[]> CACHED_FIELDS = new ConcurrentHashMap<>();

    /**
     * Get fields of the given class.
     * @param clazz the class
     * @return the fields of the given class
     */
    public static Field[] get(Class clazz) {
        Field[] fields = CACHED_FIELDS.get(clazz);
        if (fields == null) {
            fields = clazz.getFields();
            CACHED_FIELDS.putIfAbsent(clazz, fields);
        }

        return fields;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy