1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package holeg.ui.model;
- /**
- * Static counter
- * ID-Counter for all Cps Objects.
- *
- * @author Gruppe14
- */
- public class IdCounter {
- private static int counterObjects = 1;
- private static int counterElements = 1;
- public enum CounterType {
- Object, Element
- }
- /**
- * Return the next ID and increment the ID counter by 1.
- * @return the next ID
- */
- public static synchronized int nextId(CounterType type) {
- switch(type){
- case Element:
- return counterObjects++;
- case Object:
- default:
- return counterElements++;
- }
- }
- /**
- * Return the Counter.
- *
- * @return the counter
- */
- public static int actualId(CounterType type) {
- switch(type){
- case Element:
- return counterObjects;
- case Object:
- default:
- return counterElements;
- }
- }
- /**
- * Set the Counter.
- *
- * @param counter
- * the counter to set
- */
- public static void setCounter(int counter, CounterType type) {
-
- switch(type){
- case Element:
- counterElements = counter;
- case Object:
- default:
- counterObjects = counter;
- }
- }
- /**
- * Reset the Counter.
- */
- public static void resetObjectCounter(CounterType type) {
- switch(type){
- case Element:
- counterObjects = 1;
- case Object:
- default:
- counterElements = 1;
- }
- }
- }
|