View Javadoc

1   package org.kuali.rice.kns.lookup.valuefinder;
2   
3   import org.kuali.rice.kns.bo.BusinessObject;
4   import org.kuali.rice.kns.service.KNSServiceLocator;
5   import org.kuali.rice.kns.service.SequenceAccessorService;
6   
7   public class SequenceValueFinder implements ValueFinder {
8   
9       private final Class<? extends BusinessObject> associatedBo;
10      private final String sequenceName;
11  
12      public SequenceValueFinder(final Class<? extends BusinessObject> associatedBo, final String sequenceName) {
13          this.associatedBo = associatedBo;
14          this.sequenceName = sequenceName;
15      }
16  
17      /**
18       * Get the next sequence number value as a Long.
19       */
20      public final Long getLongValue() {
21      	SequenceAccessorService sas = KNSServiceLocator.getSequenceAccessorService();
22          return sas.getNextAvailableSequenceNumber(sequenceName, associatedBo);
23      }
24  
25      /**
26       * @see org.kuali.rice.kns.lookup.valuefinder.ValueFinder#getValue()
27       */
28      public final String getValue() {
29          return getLongValue().toString();
30      }
31  
32  	public final String getSequenceName() {
33  		return sequenceName;
34  	}
35  
36      public final Class<? extends BusinessObject> getAssociatedBo() {
37          return associatedBo;
38      }
39  }