view src/main/java/alice/Annotation/AliceAnnotationTest.java @ 634:69f9c5ff1df9

work reflection setKey, but not correct
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Fri, 01 Dec 2017 21:34:22 +0900
parents 746447b7c3e0
children 0423eb7fd9ee
line wrap: on
line source

package alice.Annotation;

import alice.codesegment.CreateCodeSegment;
import alice.codesegment.InputDataSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Array;
import java.lang.reflect.Method;

/**
 * Created by e125769 on 11/14/17.
 */
public class AliceAnnotationTest {
    public static void main(String[] args){
        //CreateCodeSegment createCodeSegment = new CreateCodeSegment(AliceAnnotation.class);
        //createCodeSegment.run();
        AliceAnnotation alice = new AliceAnnotation();
        //alice.ods.put("hoge", "hogehogehgoe");
        //alice.ods.put("huga", "hugahugahuga");
        //AliceAnnotationTest aliceTest = new AliceAnnotationTest();
        //aliceTest.test(alice);
    }

    public void test(AliceAnnotation alice){
        Class<AliceAnnotation> aliceAnnotationClass = AliceAnnotation.class;

        for (Field field : aliceAnnotationClass.getDeclaredFields()) {
            if (field.isAnnotationPresent(Take.class)){
                System.out.println(field.getName());
                System.out.println(field.getType());
                Take i = field.getAnnotation(Take.class);
                System.out.println(i.value());
                Receiver receiver = alice.ids.create(CommandType.TAKE);
                receiver.setKey(i.value());
            }
        }
    }
}