Last active
May 12, 2017 13:56
-
-
Save ejemba/67df829d25824a261ca5c34f9a205d01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server.java | |
@Retention(RetentionPolicy.RUNTIME) | |
@Qualifier | |
@Documented | |
public @interface Server | |
{ | |
} | |
// Main.java | |
public class Main { | |
@Server | |
Long port = 8080l; | |
@Server | |
String url = "http://localhost.local"; | |
@OtherAnno | |
Long stuff; | |
... | |
// From Main class, I want the list of field with annotation annotated with @Qualifier | |
// Arrays.* is imported | |
Field m = // the current field | |
Optional<Annotation> findFirst = stream(m.getAnnotations()) | |
.filter( a -> | |
stream( a.annotationType().getAnnotations()) | |
.anyMatch( aa -> aa.annotationType().equals(Qualifier.class)) | |
).findFirst(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment