示例#1
0
 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));
   }
 }
示例#2
0
 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);
 }
示例#3
0
    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);
    }