private GenPredicGroup addPredicsToExisting(Rule rul, GenPredicGroup previousConds) {
   List<GenPredicGroup> list = new ArrayList<GenPredicGroup>();
   GenPredicGroup gpg = getGroupConditions(rul.getRootCondition().getConditions(), null);
   list.add(gpg);
   list.add(previousConds);
   GenPredicGroup newGroup = new GenPredicGroup();
   newGroup.setMyGroups(list);
   newGroup.setOperator(EOperator.ANY);
   return newGroup;
 }
  /**
   * recursive method to get all conditions from "condition tree"
   *
   * @param conds - at the beginning root conditions, at lower level conditions under
   *     CompoundCondition
   * @param op - at the beginning null, at lower level operator of Compound Condition
   * @return group of its subgroups and of conditions
   */
  private GenPredicGroup getGroupConditions(Conditions conds, GenPredicGroup.EOperator op) {
    GenPredicGroup myConds = new GenPredicGroup();
    myConds.setOperator((op != null) ? op : GenPredicGroup.EOperator.ALL);
    Iterator<Condition> it = conds.iterator();
    while (it.hasNext()) {
      Condition cond = it.next();
      // if true, a new condition group is created and filled
      if (cond instanceof CompoundCondition) {
        // set group operator
        GenPredicGroup.EOperator actualOp = null;
        if (cond instanceof ConditionAll) {
          actualOp = GenPredicGroup.EOperator.ALL;
        } else if (cond instanceof ConditionAny) {
          actualOp = GenPredicGroup.EOperator.ANY;
        } else if (cond instanceof ConditionNone) {
          actualOp = GenPredicGroup.EOperator.NONE;
        }

        if (myConds.getMyGroups() == null) {
          myConds.setMyGroups(new ArrayList<GenPredicGroup>());
        }
        // call recursively to get conditions of actual group
        myConds
            .getMyGroups()
            .add(getGroupConditions(((CompoundCondition) cond).getConditions(), actualOp));
      } else {
        // get condition
        if (myConds.getGeneratorPredicts() == null) {
          myConds.setGeneratorPredicts(new ArrayList<GeneratorPredicate>());
        }
        myConds.getGeneratorPredicts().add(getGP(cond));
      }
    }

    return myConds;
  }
  /**
   * @param logger
   * @param context
   * @param typeName
   * @param gr
   * @return
   */
  public boolean isGenerate(
      TreeLogger logger, GeneratorContext context, String typeName, GenPredicGroup gr) {
    boolean result = false;
    if ((gr.getMyGroups() != null) && (gr.getMyGroups().size() > 0)) {
      for (GenPredicGroup group : gr.getMyGroups()) {
        switch (gr.getOperator()) {
          case ANY:
            result = result || isGenerate(logger, context, typeName, group);
            break;
          case NONE:
            result = !isGenerate(logger, context, typeName, group);
            if (!result) return false;
            break;
          case ALL:
            result = isGenerate(logger, context, typeName, group);
            if (!result) return false;
          default:
            break;
        }
      }
    }
    if ((gr.getGeneratorPredicts() != null) && (gr.getGeneratorPredicts().size() > 0)) {
      for (GeneratorPredicate entry : gr.getGeneratorPredicts()) {
        String value = null;
        try {
          switch (entry.getEPredict()) {
            case ASSIGNABLE:
              if (context
                  .getTypeOracle()
                  .findType(typeName)
                  .isAssignableTo(context.getTypeOracle().getType(entry.getValue()))) {
                value = entry.getValue();
              } else {
                value = typeName;
              }
              break;
            case TYPEIS:
              value = typeName;
              break;
            case PROPERTY:
              // ???he
              value =
                  context
                      .getPropertyOracle()
                      .getSelectionProperty(logger, entry.getName())
                      .getCurrentValue();
              break;
            default:
              value = null;
              break;
          }
        } catch (Exception e) {
          value = null;
          result = false;
        }

        if (value != null) {
          switch (gr.getOperator()) {
            case ANY:
              result = result || entry.getValue().equals(value);
              break;
            case NONE:
              result = !entry.getValue().equals(value);
              if (!result) return false;
              break;
            case ALL:
              result = entry.getValue().equals(value);
              if (!result) return false;
            default:
              break;
          }
        }
      }
    }
    return result;
  }