com.kenshoo.pl.entity.CurrentEntityMutableState Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of persistence-layer Show documentation
                Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
                
             The newest version!
        
        package com.kenshoo.pl.entity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.Collections.emptyList;
public class CurrentEntityMutableState implements CurrentEntityState {
    private final Map, Object> fields = new HashMap<>(1);
    private Map> manyByType;
    public boolean containsField(EntityField, ?> field) {
        return fields.containsKey(field);
    }
    @Override
    public  T get(EntityField, T> field) {
        //noinspection unchecked
        T value = (T) fields.get(field);
        if (value == null && !fields.containsKey(field)) {
            throw new IllegalArgumentException("Field " + field + " of entity \"" + field.getEntityType().getName() + "\" is not fetched");
        }
        return value;
    }
    @Override
    public > List> getMany(E type) {
        return manyByType == null ? emptyList() : (List) manyByType.get(type);
    }
    public  void set(EntityField, T> field, T value) {
        fields.put(field, value);
    }
    synchronized
    public > void add(E entityType, List> fieldsValueMaps) {
        if (manyByType == null) {
            manyByType = new HashMap<>();
        }
        manyByType.put(entityType, (List) fieldsValueMaps);
    }
}
            © 2015 - 2025 Weber Informatics LLC | Privacy Policy