]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/Commands.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.commands / src / org / simantics / scl / commands / Commands.java
1 package org.simantics.scl.commands;
2
3 import java.util.concurrent.ConcurrentHashMap;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.scl.commands.internal.CommandImpl;
7
8
9 public class Commands {
10     private static final ConcurrentHashMap<String, Command> COMMAND_CACHE = 
11             new ConcurrentHashMap<String, Command>();
12
13     /**
14      * Returns a command object of given type. This method always succeeds,
15      * but may return a command object whose check-method always returns fail
16      * and commit will throw an exception.
17      */
18     public static Command get(ReadGraph graph, String name) {
19         Command command = COMMAND_CACHE.get(name);
20         if(command == null) {
21             command = CommandImpl.create(graph, name);
22             COMMAND_CACHE.put(name, command);
23         }
24         return command;
25     }
26 }