private static Set<String> getSuppressed(List<CustomAnnotation> annos) { Set<String> filters = null; for (CustomAnnotation ca : annos) { String name = ca.getAnnotationType().getSimpleName(); if (!(name.startsWith("Suppress") && name.endsWith("Warning"))) continue; for (AnnotationParameter par : ca.getParameters()) { if (par.getMember().equals("value")) { AnnotationElement ae = par.getValue(); AnnotationElement[] elements = ae instanceof ArrayAnnotationElement ? ((ArrayAnnotationElement) ae) .getElements() : new AnnotationElement[] { ae }; for (AnnotationElement child : elements) { if (child instanceof ConstantAnnotationElement) { Object value = ((ConstantAnnotationElement) child).getConstantValue(); if (value instanceof String) { if (filters == null) filters = new HashSet<>(); filters.add((String) value); } } } } } } return filters == null ? Collections.emptySet() : filters; }
private static List<AssertionData> analyzeMember(MemberReference md) { List<AssertionData> assertions = new ArrayList<>(); if(md instanceof MethodDefinition && ((MethodDefinition) md).isSynthetic()) return assertions; for(CustomAnnotation anno : md.getAnnotations()) { if(anno.getAnnotationType().getFullName().equals(AssertWarning.class.getName())) { String type = ""; int minScore = 0, maxScore = 100; for(AnnotationParameter param : anno.getParameters()) { if(param.getMember().equals("value")) type = (String) ((ConstantAnnotationElement)param.getValue()).getConstantValue(); else if(param.getMember().equals("minScore")) minScore = (int) ((ConstantAnnotationElement)param.getValue()).getConstantValue(); else if(param.getMember().equals("maxScore")) maxScore = (int) ((ConstantAnnotationElement)param.getValue()).getConstantValue(); } assertions.add(new AssertionData(true, type, minScore, maxScore)); } else if(anno.getAnnotationType().getFullName().equals(AssertNoWarning.class.getName())) { String type = ""; for(AnnotationParameter param : anno.getParameters()) { if(param.getMember().equals("value")) type = (String) ((ConstantAnnotationElement)param.getValue()).getConstantValue(); } assertions.add(new AssertionData(false, type, Warning.MIN_SCORE, Warning.MAX_SCORE)); } } return assertions; }
case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue());
case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue());
case Constant: { final ConstantAnnotationElement constant = (ConstantAnnotationElement) element; return new PrimitiveExpression(Expression.MYSTERY_OFFSET, constant.getConstantValue());