コード例 #1
0
ファイル: JavaClass.java プロジェクト: Maarc/windup
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("JavaClass");
    if (typeFilterPattern != null) {
      builder.append(".inType(" + typeFilterPattern + ")");
    }
    if (referencePattern != null) {
      builder.append(".references(" + referencePattern + ")");
    }
    if (!locations.isEmpty()) {
      builder.append(".at(" + locations + ")");
    }

    if (annotationCondition != null) {
      builder.append(".annotationConditions(");
      builder.append(annotationCondition.toString());
      builder.append(")");
    }

    for (AnnotationTypeCondition condition : this.additionalAnnotationConditions) {
      builder.append(".annotationConditions(");
      builder.append(condition.toString());
      builder.append(")");
    }

    builder.append(".as(" + getVarname() + ")");
    return builder.toString();
  }
コード例 #2
0
ファイル: JavaClass.java プロジェクト: Maarc/windup
  private boolean matchAnnotationConditions(
      GraphRewrite event,
      EvaluationContext context,
      EvaluationStrategy evaluationStrategy,
      JavaTypeReferenceModel model) {
    boolean annotationMatched = true;
    if (this.annotationCondition != null) {
      annotationMatched = model instanceof JavaAnnotationTypeValueModel;

      annotationMatched &=
          annotationCondition.evaluate(
              event, context, evaluationStrategy, (JavaAnnotationTypeValueModel) model);
    }

    if (!additionalAnnotationConditions.isEmpty()) {
      JavaTypeReferenceModel referencedTypeModel;
      if (model.getReferenceLocation() == TypeReferenceLocation.ANNOTATION)
        referencedTypeModel = ((JavaAnnotationTypeReferenceModel) model).getAnnotatedType();
      else referencedTypeModel = model;

      // iterate the conditions and make sure there is at least one matching annotation for each
      for (AnnotationCondition condition : this.additionalAnnotationConditions) {
        boolean oneMatches = false;
        // now get the annotations
        for (JavaAnnotationTypeReferenceModel annotationModel :
            referencedTypeModel.getAnnotations()) {
          if (condition.evaluate(event, context, evaluationStrategy, annotationModel)) {
            oneMatches = true;
          }
        }

        if (!oneMatches) annotationMatched = false;
      }
    }

    return annotationMatched;
  }