mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
simplify some of the field setters
This commit is contained in:
parent
6703ba693d
commit
853bdac0e1
1 changed files with 2 additions and 14 deletions
|
@ -103,19 +103,7 @@ public abstract class Watcher implements Serializable {
|
|||
allFields.addAll(Arrays.asList(getClass().getSuperclass().getDeclaredFields()));
|
||||
for (Field field : allFields) {
|
||||
field.setAccessible(true);
|
||||
if (field.getType().isPrimitive()) {
|
||||
field.set(watcher, field.get(this));
|
||||
}
|
||||
else if(field.getType() == Step.class){
|
||||
field.set(watcher, field.get(this));
|
||||
}
|
||||
else if (field.getType() == Mana.class) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType() == UUID.class) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType().isEnum()) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType() == Set.class) {
|
||||
if (field.getType() == Set.class) {
|
||||
((Set) field.get(watcher)).clear();
|
||||
((Set) field.get(watcher)).addAll((Set) field.get(this));
|
||||
} else if (field.getType() == Map.class) {
|
||||
|
@ -126,7 +114,7 @@ public abstract class Watcher implements Serializable {
|
|||
((List) field.get(watcher)).addAll((List) field.get(this));
|
||||
} else {
|
||||
if (field.getType() != Logger.class) {
|
||||
logger.error(field.getType() + " can not be copied");
|
||||
field.set(watcher, field.get(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue