IdCounterElem.java 700 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package classes;
  2. /**
  3. * ID-Counter for all Holon Elements.
  4. *
  5. * @author Gruppe14
  6. */
  7. public class IdCounterElem {
  8. private static int counter = 1;
  9. /**
  10. * Return the next ID and increment the ID counter by 1.
  11. *
  12. * @return the next ID
  13. */
  14. public static synchronized int nextId() {
  15. return counter++;
  16. }
  17. /**
  18. * Return the Counter.
  19. *
  20. * @return the counter
  21. */
  22. public static int getCounter() {
  23. return counter;
  24. }
  25. /**
  26. * Set the Counter.
  27. *
  28. * @param counter
  29. * the counter to set
  30. */
  31. public static void setCounter(int counter) {
  32. IdCounterElem.counter = counter;
  33. }
  34. /**
  35. * Reset the Counter.
  36. */
  37. public static void resetCounter() {
  38. counter = 1;
  39. }
  40. }