Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.jlectra;
- import java.lang.annotation.Annotation;
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- import java.lang.reflect.Method;
- import java.util.concurrent.Callable;
- /**
- * Hello world!
- *
- */
- public class App
- {
- @Retention(RetentionPolicy.RUNTIME)
- public static @interface Annot {}
- public static interface MyCallable extends Callable<Thread>{}
- public static abstract class Foo<T extends Runnable, RT extends Callable<T>> {
- private RT obj;
- protected void setObj(RT obj) {
- this.obj = obj;
- }
- }
- public static class FooBar extends Foo<Thread, MyCallable> {
- @Override
- @Annot
- public void setObj(MyCallable obj) {
- super.setObj(obj);
- }
- }
- public static void main( String[] args ) throws Exception
- {
- FooBar fooBar = new FooBar();
- for(Method method : FooBar.class.getMethods()) {
- for(Class clazz : method.getParameterTypes()) {
- StringBuilder anns = new StringBuilder("[");
- for(Annotation ann : method.getAnnotations()) {
- anns.append(ann.annotationType().getName()).append(",");
- }
- anns.append("]");
- System.out.println(String.format("%s: %s; %s", method.getName(), clazz.getName(), anns.toString()));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement