IdCounterElem.java 803 B

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