Mercurial > hg > Database > Christie
annotate src/main/java/christie/codegear/CodeGear.java @ 3:e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 13 Dec 2017 17:24:14 +0900 |
parents | bacdcb5e6dcf |
children | 605f1b0576c2 |
rev | line source |
---|---|
0 | 1 package christie.codegear; |
2 | |
3 import christie.annotation.Take; | |
4 import christie.datagear.DataGear; | |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
5 import christie.datagear.DataGearManager; |
0 | 6 |
7 import java.lang.reflect.Field; | |
8 import java.util.ArrayList; | |
9 import java.util.HashMap; | |
10 | |
11 /** | |
12 * Created by e125769 on 12/7/17. | |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
13 * Annotationからのinputコマンドの生成、揃ったDataGearの値を返す |
0 | 14 */ |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
15 public abstract class CodeGear implements Runnable { |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
16 public InputDataGear idg = new InputDataGear(); |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
17 public OutputDataGear odg = new OutputDataGear(); |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
18 public ArrayList<Command> commandList = new ArrayList<Command>(); |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
19 public CodeGearManager cgm; |
0 | 20 |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
21 public CodeGear(CodeGearManager cgm){//AnnotationからInputDataGearをセット |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
22 this.cgm = cgm; |
2
bacdcb5e6dcf
change StartCodeGear static
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
23 odg.initODG(cgm, this); |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
24 |
0 | 25 for (Field field : this.getClass().getDeclaredFields()) { |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
26 if (field.isAnnotationPresent(Take.class)){ |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
27 Take ano = field.getAnnotation(Take.class); |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
28 commandList.add(new Command(this, null, "local", ano.value(), CommandType.TAKE)); |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
29 } |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
30 } |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
31 |
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
32 idg.finishInput(this.cgm, this, commandList); |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
33 } |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
35 public void setInputValue(){//Annotationから揃ったInputDataGearの値をキャスト |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
36 for (Field field : this.getClass().getDeclaredFields()) { |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
37 field.setAccessible(true); |
0 | 38 if (field.isAnnotationPresent(Take.class)){ |
39 Take ano = field.getAnnotation(Take.class); | |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
40 try { |
2
bacdcb5e6dcf
change StartCodeGear static
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
41 field.set(this, idg.inputValue.get(ano.value()));//ダウンキャストできるか? |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
42 } catch (IllegalAccessException e) { |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
43 e.printStackTrace(); |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 } |
0 | 45 } |
46 } | |
47 } | |
48 | |
3
e3bb0eea73f2
resolve Annotation error and TestCodeGear is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
49 public void run(){} |
0 | 50 |
51 } |