diff options
Diffstat (limited to 'sched/src/com/android/sched')
-rw-r--r-- | sched/src/com/android/sched/util/config/ConfigChecker.java | 7 | ||||
-rw-r--r-- | sched/src/com/android/sched/util/config/id/PropertyId.java | 31 |
2 files changed, 37 insertions, 1 deletions
diff --git a/sched/src/com/android/sched/util/config/ConfigChecker.java b/sched/src/com/android/sched/util/config/ConfigChecker.java index 63a21e5a..dc94c3b9 100644 --- a/sched/src/com/android/sched/util/config/ConfigChecker.java +++ b/sched/src/com/android/sched/util/config/ConfigChecker.java @@ -26,6 +26,7 @@ import com.android.sched.util.location.Location; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import javax.annotation.Nonnull; @@ -56,7 +57,11 @@ public class ConfigChecker { @Nonnull Map<ObjectId<?>, Object> instanceValues, @Nonnull Map<KeyId<?, ?>, Location> locationsById) { this.context = context; - this.values.putAll(stringValues); + for (Entry<PropertyId<?>, PropertyId<?>.Value> entry : stringValues.entrySet()) { + this.values.put(entry.getKey(), (entry.getValue() != null) ? entry.getValue().duplicate() + : null); + } + this.instances.putAll(instanceValues); this.locations.putAll(locationsById); } diff --git a/sched/src/com/android/sched/util/config/id/PropertyId.java b/sched/src/com/android/sched/util/config/id/PropertyId.java index 7086a43b..1d73382f 100644 --- a/sched/src/com/android/sched/util/config/id/PropertyId.java +++ b/sched/src/com/android/sched/util/config/id/PropertyId.java @@ -173,6 +173,15 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription { this.value = new IValueObject<T>(value); } + private Value (@Nonnull IValue<T> value) { + this.value = value.duplicate(); + } + + @Nonnull + public synchronized Value duplicate() { + return new Value(value); + } + public Value (@Nonnull CodecContext context, @Nonnull T value) { this.value = new IValueObject<T>(context, value); } @@ -221,6 +230,9 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription { @Nonnull public String getString(); + + @Nonnull + public IValue<T> duplicate(); } private class IValueString implements IValue<T> { @@ -253,6 +265,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription { public PropertyId<T>.IValueObject<T> getValueObject(@Nonnull CodecContext context) { throw new AssertionError(); } + + @Override + @Nonnull + public IValue<T> duplicate() { + return this; + } } private class IValueCheckedString implements IValue<T> { @@ -279,6 +297,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription { public PropertyId<?>.IValueObject<T> getValueObject(@Nonnull CodecContext context) { return new IValueObject<T>(context, PropertyId.this.codec.parseString(context, value)); } + + @Override + @Nonnull + public IValue<T> duplicate() { + return this; + } } private class IValueObject<T> implements IValue<T> { @@ -331,5 +355,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription { public T getObject() { return value; } + + @SuppressWarnings("unchecked") + @Override + @Nonnull + public IValue<T> duplicate() { + return ((PropertyId<T>) (PropertyId.this)).new IValueCheckedString(getString()); + } } } |