Revision 119,
885 bytes
checked in by wojtekp, 13 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Rev | Line | |
---|
[104] | 1 | package test.rewolucja.resources.utils; |
---|
| 2 | |
---|
| 3 | import java.util.HashMap; |
---|
| 4 | |
---|
| 5 | import test.rewolucja.resources.ResourceType; |
---|
| 6 | |
---|
| 7 | public class ResourceIDGenerator { |
---|
| 8 | |
---|
| 9 | private static HashMap<ResourceType, Integer> resourceCounter = new HashMap<ResourceType, Integer>(); |
---|
| 10 | |
---|
| 11 | public static int getID(ResourceType type){ |
---|
| 12 | |
---|
| 13 | //if(type == ResourceType.COMPUTING_RESOURCE) |
---|
| 14 | // reset(); |
---|
| 15 | |
---|
| 16 | int value = 0; |
---|
| 17 | if(resourceCounter.containsKey(type)){ |
---|
| 18 | value = resourceCounter.get(type); |
---|
| 19 | value++; |
---|
| 20 | } |
---|
| 21 | resourceCounter.put(type, value); |
---|
| 22 | return value; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | public static int currentHeadID(){ |
---|
[119] | 26 | if(resourceCounter.containsKey(ResourceType.DATA_CENTER)) |
---|
| 27 | return resourceCounter.get(ResourceType.DATA_CENTER); |
---|
[104] | 28 | return 0; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | /*private static void reset(){ |
---|
| 32 | for(ResourceType type:resourceCounter.keySet()){ |
---|
| 33 | if(type != ResourceType.COMPUTING_RESOURCE) |
---|
| 34 | resourceCounter.put(type, -1); |
---|
| 35 | } |
---|
| 36 | }*/ |
---|
| 37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.