@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()); }
@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; }
private ModelTypeInitializationException canNotConstructTypeException( NodeInitializerContext<?> context) { ImmutableSortedSet.Builder<ModelType<?>> constructibleTypes = ImmutableSortedSet.orderedBy(ModelTypes.displayOrder()); for (NodeInitializerExtractionStrategy extractor : additionalStrategies) { for (ModelType<?> constructibleType : extractor.supportedTypes()) { if (context.getConstraints().isSatisfiedBy(constructibleType)) { constructibleTypes.add(constructibleType); } } } return new ModelTypeInitializationException( context, schemaStore, ScalarTypes.TYPES, constructibleTypes.build()); }