ListConfigValue(SimpleConfigurationNode holder, Object startValue) { super(holder); SimpleConfigurationNode child = holder.createNode(0); child.attached = true; child.setValue(startValue); this.values.get().add(child); }
ListConfigValue(SimpleConfigurationNode holder, Object startValue) { super(holder); this.values.set(new ArrayList<>()); SimpleConfigurationNode child = holder.createNode(0); child.attached = true; child.setValue(startValue); this.values.get().add(child); }
ListConfigValue(SimpleConfigurationNode holder, Object startValue) { super(holder); SimpleConfigurationNode child = holder.createNode(0); child.attached = true; child.setValue(startValue); this.values.get().add(child); }
@Override public void setValue(Object value) { if (!(value instanceof Collection)) { value = Collections.singleton(value); } final Collection<?> valueList = (Collection<?>) value; final List<SimpleConfigurationNode> newValue = new ArrayList<>(valueList.size()); int count = 0; for (Object o : valueList) { if (o == null) { continue; } SimpleConfigurationNode child = holder.createNode(count); newValue.add(count, child); child.attached = true; child.setValue(o); ++count; } detachNodes(values.getAndSet(newValue)); }
@Override public void setValue(Object value) { if (value instanceof Map) { final ConcurrentMap<Object, SimpleConfigurationNode> newValue = newMap(); for (Map.Entry<?, ?> ent : ((Map<?, ?>) value).entrySet()) { if (ent.getValue() == null) { continue; } SimpleConfigurationNode child = holder.createNode(ent.getKey()); newValue.put(ent.getKey(), child); child.attached = true; child.setValue(ent.getValue()); } synchronized (this) { ConcurrentMap<Object, SimpleConfigurationNode> oldMap = this.values; this.values = newValue; detachChildren(oldMap); } } else { throw new IllegalArgumentException("Map configuration values can only be set to values of type Map"); } }
@Override public void setValue(@Nullable Object value) { if (!(value instanceof Collection)) { value = Collections.singleton(value); } final Collection<?> valueAsList = (Collection<?>) value; final List<SimpleConfigurationNode> newValue = new ArrayList<>(valueAsList.size()); int count = 0; for (Object o : valueAsList) { if (o == null) { continue; } SimpleConfigurationNode child = holder.createNode(count); newValue.add(count, child); child.attached = true; child.setValue(o); ++count; } detachNodes(values.getAndSet(newValue)); }
@Override public void setValue(@Nullable Object value) { if (!(value instanceof Collection)) { value = Collections.singleton(value); } final Collection<?> valueAsList = (Collection<?>) value; final List<SimpleConfigurationNode> newValue = new ArrayList<>(valueAsList.size()); int count = 0; for (Object o : valueAsList) { if (o == null) { continue; } SimpleConfigurationNode child = holder.createNode(count); newValue.add(count, child); child.attached = true; child.setValue(o); ++count; } detachNodes(values.getAndSet(newValue)); }
protected SimpleConfigurationNode getChild(Object key, boolean attach) { SimpleConfigurationNode child = value.getChild(key); if (child == null) { // Does not currently exist! if (attach) { attachIfNecessary(); SimpleConfigurationNode existingChild = value.putChildIfAbsent(key, (child = createNode(key))); if (existingChild != null) { child = existingChild; } else { attachChild(child); } } else { child = createNode(key); } } return child; }
@Override public void setValue(@Nullable Object value) { if (value instanceof Map) { final ConcurrentMap<Object, SimpleConfigurationNode> newValue = newMap(); for (Map.Entry<?, ?> ent : ((Map<?, ?>) value).entrySet()) { if (ent.getValue() == null) { continue; } SimpleConfigurationNode child = holder.createNode(ent.getKey()); newValue.put(ent.getKey(), child); child.attached = true; child.setValue(ent.getValue()); } synchronized (this) { ConcurrentMap<Object, SimpleConfigurationNode> oldMap = this.values; this.values = newValue; detachChildren(oldMap); } } else { throw new IllegalArgumentException("Map configuration values can only be set to values of type Map"); } }
@Override public void setValue(@Nullable Object value) { if (value instanceof Map) { final ConcurrentMap<Object, SimpleConfigurationNode> newValue = newMap(); for (Map.Entry<?, ?> ent : ((Map<?, ?>) value).entrySet()) { if (ent.getValue() == null) { continue; } SimpleConfigurationNode child = holder.createNode(ent.getKey()); newValue.put(ent.getKey(), child); child.attached = true; child.setValue(ent.getValue()); } synchronized (this) { ConcurrentMap<Object, SimpleConfigurationNode> oldMap = this.values; this.values = newValue; detachChildren(oldMap); } } else { throw new IllegalArgumentException("Map configuration values can only be set to values of type Map"); } }
/** * Gets a child node, relative to this. * * @param key The key * @param attach If the resultant node should be automatically attached * @return The child node */ protected SimpleConfigurationNode getChild(Object key, boolean attach) { SimpleConfigurationNode child = value.getChild(key); // child doesn't currently exist if (child == null) { if (attach) { // attach ourselves first attachIfNecessary(); // insert the child node into the value SimpleConfigurationNode existingChild = value.putChildIfAbsent(key, (child = createNode(key))); if (existingChild != null) { child = existingChild; } else { attachChild(child); } } else { // just create a new virtual (detached) node child = createNode(key); } } return child; }
/** * Gets a child node, relative to this. * * @param key The key * @param attach If the resultant node should be automatically attached * @return The child node */ protected SimpleConfigurationNode getChild(Object key, boolean attach) { SimpleConfigurationNode child = value.getChild(key); // child doesn't currently exist if (child == null) { if (attach) { // attach ourselves first attachIfNecessary(); // insert the child node into the value SimpleConfigurationNode existingChild = value.putChildIfAbsent(key, (child = createNode(key))); if (existingChild != null) { child = existingChild; } else { attachChild(child); } } else { // just create a new virtual (detached) node child = createNode(key); } } return child; }
SimpleConfigurationNode newChild = createNode(ent.getKey()); newChild.attached = true; newChild.setValue(ent.getValue());
List<? extends ConfigurationNode> children = newNode.getChildrenList(); for (int i = 0; i < children.size(); ++i) { SimpleConfigurationNode child = createNode(i); child.attached = true; newList.putChild(i, child); Map<Object, ? extends ConfigurationNode> children = newNode.getChildrenMap(); for (Map.Entry<Object, ? extends ConfigurationNode> ent : children.entrySet()) { SimpleConfigurationNode child = createNode(ent.getKey()); child.attached = true; newMap.putChild(ent.getKey(), child);
SimpleConfigurationNode newChild = createNode(ent.getKey()); newChild.attached = true; newChild.setValue(ent.getValue());
SimpleConfigurationNode newChild = createNode(ent.getKey()); newChild.attached = true; newChild.setValue(ent.getValue());