Package org.hivedb.util.functional

Examples of org.hivedb.util.functional.Generator


import org.hivedb.util.functional.Generator;

public class MemoryKeyAuthority implements KeyAuthorityCreator {
 
  public  KeyAuthority create(Class keySpace, final Class returnType) {
    final Generator incrementor;
    if (returnType.equals(int.class) || returnType.equals(Integer.class))
       incrementor = new Generator<Integer>() {
        private int i=0;;
        public Integer generate() {
          return ++i;
        }
      };
    else if (returnType.equals(long.class) || returnType.equals(Long.class))
      incrementor = new Generator<Long>() {
        private long i=0;;
        public Long generate() {
          return ++i;
        }
      };
    else
      throw new RuntimeException("Only Integers and Longs are supported");
   
    return new KeyAuthority() {

      public Object nextAvailableKey() {
        return increment();
      }
      @SuppressWarnings("unchecked")
      private Object increment()
      {
        return incrementor.generate();
      }
    };
  }
View Full Code Here

TOP

Related Classes of org.hivedb.util.functional.Generator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.