import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
import org.simantics.scl.compiler.constants.Constant;
import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {
}
- private final Function<String, SCLValue> createValue = this::createValue;
-
@Override
public SCLValue getValue(String name) {
- return values.computeIfAbsent(name, createValue);
+ if(values.containsKey(name))
+ return values.get(name);
+ else {
+ SCLValue value = createValue(name);
+ values.put(name, value);
+ return value;
+ }
}
@Override
return null;
}
- private final Function<String, SCLRelation> createRelation = this::createRelation;
-
public SCLRelation getRelation(String name) {
- return relations.computeIfAbsent(name, createRelation);
+ if(relations.containsKey(name))
+ return relations.get(name);
+ else {
+ SCLRelation relation = createRelation(name);
+ relations.put(name, relation);
+ return relation;
+ }
}
- private final Function<String, SCLEntityType> createEntityType = this::createEntityType;
-
public SCLEntityType getEntityType(String name) {
- return entityTypes.computeIfAbsent(name, createEntityType);
+ if(entityTypes.containsKey(name))
+ return entityTypes.get(name);
+ else {
+ SCLEntityType entityType = createEntityType(name);
+ entityTypes.put(name, entityType);
+ return entityType;
+ }
}
@Override