1 56 57 package org.objectstyle.cayenne.dba; 58 59 65 public final class PkRange { 66 private int curValue; 67 private int maxValue; 68 69 public PkRange(int curValue, int maxValue) { 70 reset(curValue, maxValue); 71 } 72 73 public void reset(int curValue, int maxValue) { 74 this.curValue = curValue; 75 this.maxValue = maxValue; 76 } 77 78 public boolean isExhausted() { 79 return curValue > maxValue; 80 } 81 82 public Integer getNextPrimaryKey() { 83 if (isExhausted()) { 85 throw new RuntimeException ("PkRange is exhausted and can not be used anymore."); 86 } 87 88 return new Integer (curValue++); 89 } 90 } | Popular Tags |