IdCounter.java 748 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package holeg.ui.model;
  2. /**
  3. * Static counter ID-Counter for all Cps Objects.
  4. *
  5. * @author Gruppe14
  6. */
  7. public class IdCounter {
  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 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 the counter to set
  29. */
  30. public static void set(int counter) {
  31. IdCounter.counter = counter;
  32. }
  33. /**
  34. * Reset the Counter.
  35. */
  36. public static void reset() {
  37. counter = 0;
  38. }
  39. }