void updateModel(final OperationContext context, ModelNode model, ModelNode listAttribute) throws OperationFailedException { int index = INDEX.resolveModelAttribute(context, model).asInt(); if (listAttribute.hasDefined(index)) { context.getResult().set(listAttribute.get(index)); } }
void updateModel(final OperationContext context, ModelNode model, ModelNode listAttribute) throws OperationFailedException { ModelNode value = VALUE.resolveModelAttribute(context, model); ModelNode index = INDEX.resolveModelAttribute(context, model); List<ModelNode> res = new ArrayList<>(listAttribute.asList()); if (index.isDefined()) { res.remove(index.asInt()); } else { res.remove(value); } listAttribute.set(res); }
void updateModel(final OperationContext context, ModelNode model, ModelNode listAttribute) throws OperationFailedException { String value = VALUE.resolveModelAttribute(context, model).asString(); ModelNode indexNode = INDEX.resolveModelAttribute(context, model); LinkedList<ModelNode> res = new LinkedList<>( listAttribute.isDefined() ? listAttribute.asList() : Collections.<ModelNode>emptyList()); if (indexNode.isDefined()) { res.add(indexNode.asInt(), new ModelNode(value)); } else { res.add(new ModelNode(value)); } listAttribute.set(res); }