package org.simantics.graph.compiler.internal.procedures; import org.simantics.graph.compiler.internal.store.IPreValue; import org.simantics.graph.compiler.internal.store.PreValueStore; import org.simantics.graph.query.Path; import org.simantics.graph.query.Paths; import org.simantics.graph.store.GraphStore; import gnu.trove.procedure.TIntObjectProcedure; import gnu.trove.set.hash.TIntHashSet; public class DefaultValueTyping implements Runnable { GraphStore store; Paths paths; public DefaultValueTyping(Paths paths, GraphStore store) { this.paths = paths; this.store = store; } @Override public void run() { final int instanceOfId = store.identities.createPathToId(paths.InstanceOf); final TIntHashSet instanceOfDomain = store.statements.getRelationDomain(instanceOfId); PreValueStore preValues = store.getStore(PreValueStore.class); preValues.forEachPreValue(new TIntObjectProcedure() { @Override public boolean execute(int a, IPreValue b) { if(!instanceOfDomain.contains(a)) { Path defaultType = b.getDefaultType(paths); if(defaultType != null) store.statements.add(a, instanceOfId, store.identities.createPathToId(defaultType) ); } return true; } }); } }