@Override public ModelView<Set<T>> toView( MutableModelNode modelNode, ModelRuleDescriptor ruleDescriptor, boolean writable) { ModelType<Set<T>> setType = ModelTypes.set(elementType); DefaultModelViewState state = new DefaultModelViewState(setType, ruleDescriptor, writable, !writable); SetBackedCollection<T> set = new SetBackedCollection<T>(modelNode, state, elementType); return InstanceModelView.of(modelNode.getPath(), setType, set, state.closer()); }
@Override protected <T, E> NodeInitializer extractNodeInitializer( ModelCollectionSchema<T, E> schema, NodeInitializerRegistry nodeInitializerRegistry) { ModelType<T> type = schema.getType(); Class<? super T> rawClass = type.getRawClass(); ModelType<? super T> rawCollectionType = ModelType.of(rawClass); if (TYPES.contains(rawCollectionType)) { if (schema.getType().getRawClass() == List.class) { return new ProjectionOnlyNodeInitializer( ScalarCollectionModelProjection.get( ModelTypes.list(schema.getElementType()), new ListViewFactory<E>(schema.getElementType()))); } else { return new ProjectionOnlyNodeInitializer( ScalarCollectionModelProjection.get( ModelTypes.set(schema.getElementType()), new SetViewFactory<E>(schema.getElementType()))); } } return null; }