예제 #1
0
 private Collection4 introduceClassConstrain(ReflectClass claxx) {
   final Collection4 newConstraints = new Collection4();
   final Iterator4 existingConstraints = iterateConstraints();
   while (existingConstraints.moveNext()) {
     final QCon existingConstraint = (QConObject) existingConstraints.current();
     final BooleanByRef removeExisting = new BooleanByRef(false);
     final QCon newConstraint = existingConstraint.shareParentForClass(claxx, removeExisting);
     if (newConstraint != null) {
       newConstraints.add(newConstraint);
       addConstraint(newConstraint);
       if (removeExisting.value) {
         removeConstraint(existingConstraint);
       }
     }
   }
   return newConstraints;
 }
예제 #2
0
 private List4 createQCandidatesList() {
   List4 candidatesList = null;
   Iterator4 i = iterateConstraints();
   while (i.moveNext()) {
     QCon constraint = (QCon) i.current();
     constraint = constraint.getRoot();
     ClassMetadata classMetadata = constraint.getYapClass();
     if (classMetadata == null) {
       continue;
     }
     if (constraintCanBeAddedToExisting(candidatesList, constraint)) {
       continue;
     }
     QCandidates candidates = new QCandidates((LocalTransaction) _trans, classMetadata, null);
     candidatesList = new List4(candidatesList, candidates);
   }
   return candidatesList;
 }
예제 #3
0
 public CreateCandidateCollectionResult createCandidateCollection() {
   List4 candidatesList = createQCandidatesList();
   boolean checkDuplicates = false;
   boolean topLevel = true;
   Iterator4 i = iterateConstraints();
   while (i.moveNext()) {
     QCon constraint = (QCon) i.current();
     QCon old = constraint;
     constraint = constraint.getRoot();
     if (constraint != old) {
       checkDuplicates = true;
       topLevel = false;
     }
     ClassMetadata classMetadata = constraint.getYapClass();
     if (classMetadata == null) {
       break;
     }
     addConstraintToCandidatesList(candidatesList, constraint);
   }
   return new CreateCandidateCollectionResult(candidatesList, checkDuplicates, topLevel);
 }
예제 #4
0
  private boolean forEachConstraintRecursively(Function4 block) {
    Queue4 queue = new NoDuplicatesQueue(new NonblockingQueue());
    Iterator4 constrIter = iterateConstraints();
    while (constrIter.moveNext()) {
      queue.add(constrIter.current());
    }
    while (queue.hasNext()) {
      QCon constr = (QCon) queue.next();
      Boolean cancel = (Boolean) block.apply(constr);
      if (cancel.booleanValue()) {
        return true;
      }

      Iterator4 childIter = constr.iterateChildren();
      while (childIter.moveNext()) {
        queue.add(childIter.current());
      }
      Iterator4 joinIter = constr.iterateJoins();
      while (joinIter.moveNext()) {
        queue.add(joinIter.current());
      }
    }
    return false;
  }
예제 #5
0
 private boolean attachToExistingConstraints(
     Collection4 newConstraintsCollector, Object obj, boolean onlyForPaths) {
   boolean found = false;
   final Iterator4 j = iterateConstraints();
   while (j.moveNext()) {
     QCon existingConstraint = (QCon) j.current();
     final BooleanByRef removeExisting = new BooleanByRef(false);
     if (!onlyForPaths || (existingConstraint instanceof QConPath)) {
       QCon newConstraint = existingConstraint.shareParent(obj, removeExisting);
       if (newConstraint != null) {
         newConstraintsCollector.add(newConstraint);
         addConstraint(newConstraint);
         if (removeExisting.value) {
           removeConstraint(existingConstraint);
         }
         found = true;
         if (!onlyForPaths) {
           break;
         }
       }
     }
   }
   return found;
 }