From 853bdac0e1892a8b99c4f5e5bd2aea7558917566 Mon Sep 17 00:00:00 2001 From: Ingmar Goudt Date: Tue, 30 Apr 2019 16:41:06 +0200 Subject: [PATCH] simplify some of the field setters --- Mage/src/main/java/mage/watchers/Watcher.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Mage/src/main/java/mage/watchers/Watcher.java b/Mage/src/main/java/mage/watchers/Watcher.java index f954166119..05efdc76f3 100644 --- a/Mage/src/main/java/mage/watchers/Watcher.java +++ b/Mage/src/main/java/mage/watchers/Watcher.java @@ -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)); } } }