private static String toMessage(
     NodeInitializerContext context,
     ModelSchemaStore schemaStore,
     Iterable<ModelType<?>> scalarTypes,
     Iterable<ModelType<?>> constructableTypes) {
   Optional<ModelProperty<?>> modelPropertyOptional = context.getModelProperty();
   StringBuffer s = new StringBuffer();
   if (modelPropertyOptional.isPresent()) {
     s.append(
         String.format(
             "A model element of type: '%s' can not be constructed.%n",
             context.getContainingType().get().getName()));
     ModelProperty<?> modelProperty = modelPropertyOptional.get();
     if (isManagedCollection(modelProperty.getType())) {
       s.append(
           String.format(
               "Its property '%s %s' is not a valid managed collection%n",
               modelProperty.getType().getName(), modelProperty.getName()));
       ModelCollectionSchema<?, ?> schema =
           (ModelCollectionSchema) schemaStore.getSchema(modelProperty.getType());
       s.append(
           String.format("A managed collection can not contain '%s's%n", schema.getElementType()));
       appendManagedCollections(s, 1, constructableTypes);
     } else if (isScalarCollection(modelProperty.getType(), schemaStore)) {
       ModelCollectionSchema<?, ?> schema =
           (ModelCollectionSchema) schemaStore.getSchema(modelProperty.getType());
       s.append(
           String.format(
               "Its property '%s %s' is not a valid scalar collection%n",
               modelProperty.getType().getName(), modelProperty.getName()));
       s.append(
           String.format("A scalar collection can not contain '%s's%n", schema.getElementType()));
       s.append(explainScalarCollections(scalarTypes));
     } else {
       s.append(
           String.format(
               "Its property '%s %s' can not be constructed%n",
               modelProperty.getType().getName(), modelProperty.getName()));
       s.append(String.format("It must be one of:%n"));
       s.append(String.format("    - %s%n", MANAGED_TYPE_DESCRIPTION));
       s.append("    - A managed collection. ");
       appendManagedCollections(s, 1, constructableTypes);
       s.append(
           String.format(
               "%n    - A scalar collection. %s%n    - %s",
               explainScalarCollections(scalarTypes), UNMANAGED_PROPERTY_DESCRIPTION));
       maybeAppendConstructables(s, constructableTypes, 1);
     }
   } else {
     s.append(
         String.format(
             "A model element of type: '%s' can not be constructed.%n",
             context.getModelType().getName()));
     s.append(String.format("It must be one of:%n"));
     s.append(String.format("    - %s", MANAGED_TYPE_DESCRIPTION));
     maybeAppendConstructables(s, constructableTypes, 1);
   }
   return s.toString();
 }
 @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;
 }