@Test public void testOptions() { Schema schema = parseSchema(TestType.class); Map<String, Field> fields = schema.getResourceFields(); assertNull(fields.get("defaultSettings").getOptions()); List<String> options = fields.get("typeEnum").getOptions(); assertEquals(2, options.size()); assertEquals("FIRST", options.get(0)); assertEquals("SECOND", options.get(1)); }
@Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; }
SchemaFactoryImpl extends AbstractSchemaFactory implements SchemaFactory { @Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; } }
SchemaFactoryImpl extends AbstractSchemaFactory implements SchemaFactory { @Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; } SchemaFactoryImpl(); }
SchemaFactoryImpl extends AbstractSchemaFactory implements SchemaFactory { @Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; } SchemaFactoryImpl(); @Override String getId(); @io.github.ibuildthecloud.gdapi.annotation.Field Object getDefaultField(); @Override Schema registerSchema(Object obj); @Override Schema getSchema(Class<?> clz); @Override Schema parseSchema(String name); @PostConstruct void init(); @Override List<Schema> listSchemas(); @Override Schema getSchema(String type); @Override Class<?> getSchemaClass(String type); List<Class<?>> getTypes(); void setTypes(List<Class<?>> types); List<SchemaPostProcessor> getPostProcessors(); @Inject void setPostProcessors(List<SchemaPostProcessor> postProcessors); List<String> getTypeNames(); void setTypeNames(List<String> typeNames); boolean isIncludeDefaultTypes(); void setIncludeDefaultTypes(boolean includeDefaultTypes); boolean isWritableByDefault(); void setWritableByDefault(boolean writableByDefault); void setId(String id); }
SchemaFactoryImpl extends AbstractSchemaFactory implements SchemaFactory { @Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; } SchemaFactoryImpl(); @Override String getId(); @io.github.ibuildthecloud.gdapi.annotation.Field Object getDefaultField(); @Override Schema registerSchema(Object obj); @Override Schema getSchema(Class<?> clz); @Override Schema parseSchema(String name); @PostConstruct void init(); @Override List<Schema> listSchemas(); @Override Schema getSchema(String type); @Override Class<?> getSchemaClass(String type); List<Class<?>> getTypes(); void setTypes(List<Class<?>> types); List<SchemaPostProcessor> getPostProcessors(); @Inject void setPostProcessors(List<SchemaPostProcessor> postProcessors); List<String> getTypeNames(); void setTypeNames(List<String> typeNames); boolean isIncludeDefaultTypes(); void setIncludeDefaultTypes(boolean includeDefaultTypes); boolean isWritableByDefault(); void setWritableByDefault(boolean writableByDefault); void setId(String id);  }