package org.simantics.db.layer0.variable; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; abstract public class VariableMapImpl implements VariableMap { @Override public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException { return getVariables(graph, context, null).get(name); } @Override public Map getVariables(ReadGraph graph, Variable context, String classification, Map map) throws DatabaseException { Map all = getVariables(graph, context, null); if(all.isEmpty()) return all; for(Map.Entry entry : all.entrySet()) { Set classifications = entry.getValue().getClassifications(graph); if(classifications.contains(classification)) { if(map == null) map = new HashMap(); map.put(entry.getKey(), entry.getValue()); } } return map; } }