Mercurial > hg > Database > Christie
comparison src/main/java/christie/codegear/CodeGear.java @ 31:e29900328fff
remove RemoteTake annotation
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Feb 2018 18:29:37 +0900 |
parents | d1fc3ebb269e |
children | 307ac87ddcf7 |
comparison
equal
deleted
inserted
replaced
30:250ae646db7f | 31:e29900328fff |
---|---|
1 package christie.codegear; | 1 package christie.codegear; |
2 | 2 |
3 import christie.annotation.Peek; | 3 import christie.annotation.Peek; |
4 import christie.annotation.RemoteTake; | |
5 import christie.annotation.Take; | 4 import christie.annotation.Take; |
6 import christie.datagear.*; | 5 import christie.datagear.*; |
7 import christie.datagear.command.Command; | 6 import christie.datagear.command.Command; |
8 import christie.datagear.command.PeekCommand; | 7 import christie.datagear.command.PeekCommand; |
9 import christie.datagear.command.TakeCommand; | 8 import christie.datagear.command.TakeCommand; |
31 this.localDGM = cgm.getLocalDGM(); | 30 this.localDGM = cgm.getLocalDGM(); |
32 | 31 |
33 for (Field field : this.getClass().getDeclaredFields()) {//AnnotationからInputDataGearをセット | 32 for (Field field : this.getClass().getDeclaredFields()) {//AnnotationからInputDataGearをセット |
34 if (field.isAnnotationPresent(Take.class)) { | 33 if (field.isAnnotationPresent(Take.class)) { |
35 Take ano = field.getAnnotation(Take.class); | 34 Take ano = field.getAnnotation(Take.class); |
36 setTakeCommand("local", ano.value(), initDataGear(field, ano.value())); | 35 setTakeCommand(ano.value(), field.getName(), new DataGear(field.getType())); |
37 } else if (field.isAnnotationPresent(Peek.class)) { | 36 } else if (field.isAnnotationPresent(Peek.class)) { |
38 Peek ano = field.getAnnotation(Peek.class); | 37 Peek ano = field.getAnnotation(Peek.class); |
39 setPeekCommand("local", ano.value(), initDataGear(field, ano.value())); | 38 setPeekCommand(ano.value(), field.getName(), new DataGear(field.getType())); |
40 } else if (field.isAnnotationPresent(RemoteTake.class)) { | |
41 RemoteTake ano = field.getAnnotation(RemoteTake.class); | |
42 setTakeCommand(ano.dgmName(), ano.key(), initDataGear(field, ano.key())); | |
43 } | 39 } |
44 //ToDo:add remote peek | 40 //ToDo:add remote peek |
45 } | 41 } |
46 | 42 |
47 idg.finishInput(cgm, commandList); | 43 idg.finishInput(cgm, commandList); |
48 } | |
49 | |
50 public DataGear initDataGear(Field field, String key){ | |
51 if (!field.getName().equals(key)){ | |
52 throw new IllegalArgumentException("key and DataGearName do not match"); | |
53 } | |
54 | |
55 DataGear dg = null; | |
56 try { | |
57 dg = (DataGear) field.get(this); | |
58 } catch (IllegalAccessException e) { | |
59 e.printStackTrace(); | |
60 } | |
61 | |
62 if (dg.getClazz() == null){ | |
63 throw new NullPointerException("please initialize DataGear"); | |
64 } | |
65 | |
66 return dg; | |
67 } | 44 } |
68 | 45 |
69 public void setTakeCommand(String toDgmName, String key, DataGear dg){ | 46 public void setTakeCommand(String toDgmName, String key, DataGear dg){ |
70 commandList.add(new TakeCommand(this, cgm.cgmID, toDgmName, key, dg)); | 47 commandList.add(new TakeCommand(this, cgm.cgmID, toDgmName, key, dg)); |
71 } | 48 } |