public void execute( final MutableModelNode modelNode, final T binary, List<ModelView<?>> inputs) { NamedEntityInstantiator<Task> taskFactory = Cast.uncheckedCast(ModelViews.getInstance(inputs.get(0), ITaskFactory.class)); ModelMap<Task> cast = DomainObjectCollectionBackedModelMap.wrap( Task.class, binary.getTasks(), taskFactory, new Task.Namer(), new Action<Task>() { @Override public void execute(Task task) { binary.getTasks().add(task); binary.builtBy(task); } }); List<ModelView<?>> inputsWithBinary = new ArrayList<ModelView<?>>(inputs.size()); inputsWithBinary.addAll(inputs.subList(1, inputs.size())); inputsWithBinary.add( InstanceModelView.of(getSubject().getPath(), getSubject().getType(), binary)); invoke(inputsWithBinary, cast, binary, binary); }
@Override public ModelView<List<T>> toView( MutableModelNode modelNode, ModelRuleDescriptor ruleDescriptor, boolean writable) { ModelType<List<T>> listType = ModelTypes.list(elementType); DefaultModelViewState state = new DefaultModelViewState(listType, ruleDescriptor, writable, !writable); ListBackedCollection<T> list = new ListBackedCollection<T>(modelNode, state, elementType); return InstanceModelView.of(modelNode.getPath(), listType, list, state.closer()); }