private void insertNewValue(Object newValue, boolean onlyIfNull) { attachIfNecessary(); synchronized (this) { ConfigValue oldValue, value; oldValue = value = this.value; if (onlyIfNull && !(oldValue instanceof NullConfigValue)){ return; } if (newValue instanceof Collection) { if (!(value instanceof ListConfigValue)) { value = new ListConfigValue(this); } } else if (newValue instanceof Map) { if (!(value instanceof MapConfigValue)) { value = new MapConfigValue(this); } } else if (!(value instanceof ScalarConfigValue)) { value = new ScalarConfigValue(this); } value.setValue(newValue); /*if (oldValue != null && oldValue != value) { oldValue.clear(); }*/ this.value = value; } }
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; }
ConfigurationNode newNode = (ConfigurationNode) newValue; if (newNode.hasListChildren()) { attachIfNecessary(); ListConfigValue newList = new ListConfigValue(this); synchronized (newNode) { return this; } else if (newNode.hasMapChildren()) { attachIfNecessary(); MapConfigValue newMap = new MapConfigValue(this); synchronized (newNode) {
/** * 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; }
attachIfNecessary(); ListConfigValue newList = new ListConfigValue(this); synchronized (newValueAsNode) { attachIfNecessary(); MapConfigValue newMap = new MapConfigValue(this); synchronized (newValueAsNode) {
attachIfNecessary(); ListConfigValue newList = new ListConfigValue(this); synchronized (newValueAsNode) { attachIfNecessary(); MapConfigValue newMap = new MapConfigValue(this); synchronized (newValueAsNode) {