Package org.cruxframework.crux.core.client.db.annotation.Store

Examples of org.cruxframework.crux.core.client.db.annotation.Store.Key


    boolean result = false;
   
    List<JMethod> getterMethods = JClassUtils.getGetterMethods(targetObject);
    for (JMethod method : getterMethods)
        {
          Key key = method.getAnnotation(Key.class);
      if (key != null)
          {
        if (result && !key.autoIncrement())
        {
          throw new CruxGeneratorException("Invalid composite key declaration on objectStore ["+targetObject.getQualifiedSourceName()+"]. Can not use autoIncrement only on subset on keyPath set.");
        }
        if (key.autoIncrement() && !method.getReturnType().getQualifiedSourceName().equals("int") &&
          !method.getReturnType().getQualifiedSourceName().equals(Integer.class.getCanonicalName()))
        {
          throw new CruxGeneratorException("Invalid key declaration on objectStore ["+targetObject.getQualifiedSourceName()+"]. Can not use autoIncrement on a non int key.");
        }
            result = key.autoIncrement();
          }
        }
    return result;
  }
View Full Code Here


    List<JMethod> getterMethods = JClassUtils.getGetterMethods(targetObject);
   
    for (JMethod method : getterMethods)
        {
          Key key = method.getAnnotation(Key.class);
      if (key != null)
          {
            if (!isValidTypeForKey(method.getReturnType()))
            {
              throw new CruxGeneratorException("Invalid key type for key on method ["+method.getReadableDeclaration()+"]. Crux databases only support Strings, integers, double or dates as part of a key or index");
            }
            keys.add(key);
            keyPath.add(JClassUtils.getPropertyForGetterOrSetterMethod(method));
          }
        }
    for (int i=0; i< keys.size(); i++)
    {
      int orderI = keys.get(i).order();
      if (orderI < 0 && keys.size() > 1)
      {
            throw new CruxGeneratorException("Crux object stores with composite keys must declare a valid order for its key's components");
      }
      int pos = i;
      for (int j=i+1; j < keys.size(); j++)
      {
        int orderJ = keys.get(j).order();
        if (orderJ < orderI)
        {
          orderI = orderJ;
          pos = j;
        }
      }
      if (pos != i)
      {
        Key key = keys.remove(pos);
        keys.add(i, key);
        String path = keyPath.remove(pos);
        keyPath.add(i, path);
      }
    }
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.client.db.annotation.Store.Key

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.