/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */

package net.ranides.assira.reflection.impl;

import java.lang.reflect.Field;
import net.ranides.assira.collection.maps.Cache;
import net.ranides.assira.reflection.IContext;
import net.ranides.assira.reflection.IField;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public final class FField {
    
    private static final Cache<Object, IField> D_CACHE = new Cache<>();
    private static final Cache<Object, IField> R_CACHE = new Cache<>();
    
    private FField() {
        /* utility class */
    }

    public static IField newField(boolean declared, IContext context, Field field) {
        return (declared ? D_CACHE : R_CACHE).get(field, () -> new RField(declared, context, field));
    }
    
    public static IField newField(IContext context, Field field) {
        return newField(true, context, field);
    }
    
}
