Exemple #1
0
 private Constraint addInterfaceConstraint(ReflectClass claxx) {
   Collection4 classes = stream().classCollection().forInterface(claxx);
   if (classes.size() == 0) {
     QConClass qcc = new QConClass(_trans, null, null, claxx);
     addConstraint(qcc);
     return qcc;
   }
   Iterator4 i = classes.iterator();
   Constraint constr = null;
   while (i.moveNext()) {
     ClassMetadata classMetadata = (ClassMetadata) i.current();
     ReflectClass classMetadataClaxx = classMetadata.classReflector();
     if (classMetadataClaxx != null) {
       if (!classMetadataClaxx.isInterface()) {
         if (constr == null) {
           constr = constrain(classMetadataClaxx);
         } else {
           constr = constr.or(constrain(classMetadata.classReflector()));
         }
       }
     }
   }
   return constr;
 }
Exemple #2
0
  private Constraint addClassConstraint(ReflectClass claxx) {
    if (isTheObjectClass(claxx)) {
      return null;
    }

    if (claxx.isInterface()) {
      return addInterfaceConstraint(claxx);
    }

    final Collection4 newConstraints = introduceClassConstrain(claxx);
    if (newConstraints.isEmpty()) {
      QConClass qcc = new QConClass(_trans, claxx);
      addConstraint(qcc);
      return qcc;
    }

    return toConstraint(newConstraints);
  }
  /**
   * This is to ensure that reflector.forObject(GenericArray) returns an instance of
   * GenericArrayClass instead of GenericClass http://tracker.db4o.com/jira/browse/COR-376
   */
  public void testGenericArrayClass() {
    ExtObjectContainer oc = fixture().db();
    initGenericObjects();
    ReflectClass elementType = oc.reflector().forName(PERSON_CLASSNAME);

    Object array = reflector().array().newInstance(elementType, 5);

    ReflectClass arrayClass = oc.reflector().forObject(array);
    Assert.isTrue(arrayClass.isArray());
    Assert.isTrue(arrayClass instanceof GenericArrayClass);

    arrayClass = oc.reflector().forName(array.getClass().getName());
    Assert.isTrue(arrayClass.isArray());
    Assert.isTrue(arrayClass instanceof GenericArrayClass);

    arrayClass = oc.reflector().forClass(array.getClass());
    Assert.isTrue(arrayClass.isArray());
    Assert.isTrue(arrayClass instanceof GenericArrayClass);

    Assert.areEqual(arrayClass.getName(), ReflectPlatform.fullyQualifiedName(array.getClass()));

    Assert.areEqual("(GA) " + elementType.getName(), array.toString());
  }
Exemple #4
0
 private boolean isTheObjectClass(ReflectClass claxx) {
   return claxx.equals(stream()._handlers.ICLASS_OBJECT);
 }