<target interface="org.simantics.db.layer0.variable.VariableBuilder">
<type uri="http://www.simantics.org/Layer0-0.0/Entity"
- class="org.simantics.db.layer0.variable.StandardVariableBuilder" >
+ class="org.simantics.db.layer0.variable.StandardVariableBuilder"
+ constructor="get" >
</type>
</target>
public class StandardVariableBuilder<Node> implements VariableBuilder<Node> {
- @Override
- public Variable buildChild(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource child) {
- return new StandardGraphChildVariable(parent, node, child);
- }
-
- @Override
- public Variable buildProperty(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource subject, Resource predicate) throws DatabaseException {
- return new StandardGraphPropertyVariable(graph, parent, node, subject, predicate);
- }
+ private static StandardVariableBuilder<?> INSTANCE = null;
+
+ private StandardVariableBuilder() {}
+
+ public static synchronized StandardVariableBuilder<?> get() {
+ if(INSTANCE == null) {
+ INSTANCE = new StandardVariableBuilder<>();
+ }
+ return INSTANCE;
+ }
+
+ @Override
+ public Variable buildChild(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource child) {
+ return new StandardGraphChildVariable(parent, node, child);
+ }
+
+ @Override
+ public Variable buildProperty(ReadGraph graph, Variable parent, VariableNode<Node> node, Resource subject, Resource predicate) throws DatabaseException {
+ return new StandardGraphPropertyVariable(graph, parent, node, subject, predicate);
+ }
}