Mercurial > hg > Database > Christie
comparison src/main/java/christie/codegear/CodeGear.java @ 23:695705dba324
Increased commands by type
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 Jan 2018 17:46:55 +0900 |
parents | 77583ea56656 |
children | 76fac42a840e |
comparison
equal
deleted
inserted
replaced
22:77583ea56656 | 23:695705dba324 |
---|---|
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; | 4 import christie.annotation.RemoteTake; |
5 import christie.annotation.Take; | 5 import christie.annotation.Take; |
6 import christie.datagear.Command; | 6 import christie.datagear.*; |
7 import christie.datagear.CommandType; | 7 import christie.datagear.Command.Command; |
8 import christie.datagear.DataGear; | 8 import christie.datagear.Command.TakeCommand; |
9 import christie.datagear.DataGearManager; | |
10 | 9 |
11 import java.lang.reflect.Field; | 10 import java.lang.reflect.Field; |
12 import java.util.ArrayList; | 11 import java.util.ArrayList; |
13 | 12 |
14 /** | 13 /** |
32 odg.initODG(cgm); | 31 odg.initODG(cgm); |
33 | 32 |
34 for (Field field : this.getClass().getDeclaredFields()) {//AnnotationからInputDataGearをセット | 33 for (Field field : this.getClass().getDeclaredFields()) {//AnnotationからInputDataGearをセット |
35 if (field.isAnnotationPresent(Take.class)) { | 34 if (field.isAnnotationPresent(Take.class)) { |
36 Take ano = field.getAnnotation(Take.class); | 35 Take ano = field.getAnnotation(Take.class); |
37 checkAndSetCommand(field, "local", ano.value()); | 36 createCommand(field, "local", ano.value()); |
38 } else if (field.isAnnotationPresent(Peek.class)) { | 37 } else if (field.isAnnotationPresent(Peek.class)) { |
39 Peek ano = field.getAnnotation(Peek.class); | 38 Peek ano = field.getAnnotation(Peek.class); |
40 checkAndSetCommand(field, "local", ano.value()); | 39 createCommand(field, "local", ano.value()); |
41 } else if (field.isAnnotationPresent(RemoteTake.class)) { | 40 } else if (field.isAnnotationPresent(RemoteTake.class)) { |
42 RemoteTake ano = field.getAnnotation(RemoteTake.class); | 41 RemoteTake ano = field.getAnnotation(RemoteTake.class); |
43 checkAndSetCommand(field, ano.dsmName(), ano.key()); | 42 createCommand(field, ano.dsmName(), ano.key()); |
44 } | 43 } |
44 //ToDo:add peek | |
45 } | 45 } |
46 | 46 |
47 idg.finishInput(cgm, commandList); | 47 idg.finishInput(cgm, commandList); |
48 } | 48 } |
49 | 49 |
50 public void checkAndSetCommand(Field field, String dsmName, String key){ | 50 public void createCommand(Field field, String toDsmName, String key){ |
51 | 51 |
52 if (!field.getName().equals(key)){ | 52 if (!field.getName().equals(key)){ |
53 throw new IllegalArgumentException("key and DataGearName do not match"); | 53 throw new IllegalArgumentException("key and DataGearName do not match"); |
54 } | 54 } |
55 | 55 |
62 | 62 |
63 if (dg.getClazz() == null){ | 63 if (dg.getClazz() == null){ |
64 throw new NullPointerException("please initialize DataGear"); | 64 throw new NullPointerException("please initialize DataGear"); |
65 } | 65 } |
66 | 66 |
67 commandList.add(new Command(CommandType.TAKE, this, cgm.cgmID, dsmName, key, dg, dg.getClazz(), null)); | 67 commandList.add(new TakeCommand(this, cgm.cgmID, toDsmName, key, dg)); |
68 } | 68 } |
69 | 69 |
70 public DataGearManager getLocalDGM() { | 70 public DataGearManager getLocalDGM() { |
71 return localDGM; | 71 return localDGM; |
72 } | 72 } |