IdCounter.java 729 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package holeg.ui.model;
  2. /**
  3. * Static counter
  4. * ID-Counter for all Cps Objects.
  5. *
  6. * @author Gruppe14
  7. */
  8. public class IdCounter {
  9. private static int counter = 1;
  10. /**
  11. * Return the next ID and increment the ID counter by 1.
  12. * @return the next ID
  13. */
  14. public static synchronized int next() {
  15. return counter++;
  16. }
  17. /**
  18. * Return the Counter.
  19. *
  20. * @return the counter
  21. */
  22. public static int get() {
  23. return counter;
  24. }
  25. /**
  26. * Set the Counter.
  27. *
  28. * @param counter
  29. * the counter to set
  30. */
  31. public static void set(int counter) {
  32. IdCounter.counter = counter;
  33. }
  34. /**
  35. * Reset the Counter.
  36. */
  37. public static void reset() {
  38. counter = 0;
  39. }
  40. }