public static Map < ExecutableElement , AnnotationValue > getElementValuesWithDefaults ( AnnotationMirror annotMirror ) { Map < ExecutableElement , AnnotationValue > valMap = Optional . ofNullable ( ( Map < ExecutableElement , AnnotationValue > ) annotMirror . getElementValues ( ) ) . map ( x -> new HashMap <> ( x ) ) . orElse ( new HashMap <> ( ) ) ; ElementFilter . methodsIn ( annotMirror . getAnnotationType ( ) . asElement ( ) . getEnclosedElements ( ) ) . stream ( ) . map ( annot -> Tuple2 . of ( annot , annot . getDefaultValue ( ) ) ) . filter ( tuple2 -> tuple2 . _2 ( ) != null && ! valMap . containsKey ( tuple2 . _1 ( ) ) ) . forEach ( tuple2 -> valMap . put ( tuple2 . _1 ( ) , tuple2 . _2 ( ) ) ) ; return valMap ; }
Returns the values of an annotation s attributes including defaults . The method with the same name in JavacElements cannot be used directly because it includes a cast to Attribute . Compound which doesn t hold for annotations generated by the Checker Framework .