org.raml.v2.api.model.v10.datamodel.ArrayTypeDeclaration Java Examples
The following examples show how to use
org.raml.v2.api.model.v10.datamodel.ArrayTypeDeclaration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnionTypesHelper.java From raml-java-tools with Apache License 2.0 | 6 votes |
private static Map<Class<? extends TypeDeclaration>, Integer> getPriorityTypeMap() { return new ImmutableMap.Builder<Class<? extends TypeDeclaration>, Integer>() .put(NullTypeDeclaration.class, 1) .put(BooleanTypeDeclaration.class, 2) .put(IntegerTypeDeclaration.class, 3) .put(NumberTypeDeclaration.class, 4) .put(DateTypeDeclaration.class, 5) .put(TimeOnlyTypeDeclaration.class, 6) .put(DateTimeOnlyTypeDeclaration.class, 7) .put(DateTimeTypeDeclaration.class, 8) .put(StringTypeDeclaration.class, 9) .put(ObjectTypeDeclaration.class, 10) .put(ArrayTypeDeclaration.class, 11) .put(UnionTypeDeclaration.class, 12) .put(FileTypeDeclaration.class, 13) .put(AnyTypeDeclaration.class, 14) .build(); }
Example #2
Source File: CovariantListPlugin.java From raml-java-tools with Apache License 2.0 | 5 votes |
private boolean isNotTargetDefaultType(ObjectPluginContext objectPluginContext, TypeDeclaration declaration, List<String> arguments) { if (!(declaration instanceof ArrayTypeDeclaration)) { return true; } ArrayTypeDeclaration arrayTypeDeclaration = (ArrayTypeDeclaration) declaration; TypeDeclaration itemTypes = arrayTypeDeclaration.items(); if (!(itemTypes instanceof ObjectTypeDeclaration)) { return true; } return arguments.size() == 0 && objectPluginContext.childClasses(itemTypes.name()).isEmpty(); }
Example #3
Source File: AsArray.java From raml-java-tools with Apache License 2.0 | 5 votes |
@Override public TypeName typeName(ReferencePluginContext referencePluginContext, TypeDeclaration ramlType, TypeName currentSuggestion) { if ( ramlType instanceof ArrayTypeDeclaration) { return ArrayTypeName.of(((ParameterizedTypeName)currentSuggestion).typeArguments.get(0).box()); } else { return currentSuggestion; } }
Example #4
Source File: ArrayTypeInterpreter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
private JClass resolveCollectionClass(ArrayTypeDeclaration arrayType, JClass resolvedClass, JCodeModel builderModel) { Class<?> container = List.class; if (arrayType.uniqueItems() != null && arrayType.uniqueItems()) { container = Set.class; } return builderModel.ref(container).narrow(resolvedClass); }
Example #5
Source File: RJP10V2RamlRootTest.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Test public void ramlRootShouldReflectDataTypes() { Map<String, RamlDataType> personType = ramlRoot.getTypes(); ObjectTypeDeclaration personDataType = (ObjectTypeDeclaration) personType.get("Person").getType(); assertThat(personDataType.displayName().value(), equalTo("Person")); assertThat(personDataType.type(), equalTo("object")); StringTypeDeclaration testXProp = (StringTypeDeclaration) personDataType.properties().get(0); assertThat(testXProp.displayName().value(), equalTo("testX")); assertThat(testXProp.defaultValue(), equalTo("def_value")); assertThat(testXProp.minLength(), equalTo(3)); assertThat(testXProp.maxLength(), equalTo(10)); ArrayTypeDeclaration testY = (ArrayTypeDeclaration) personDataType.properties().get(1); assertThat(testY.description().value(), equalTo("array attribute")); assertThat(testY.example().value(), endsWith("[\n\"a\",\n\"b\"\n]")); assertThat(testY.items().type(), equalTo("string")); assertThat(testY.minItems(), equalTo(2)); assertThat(testY.maxItems(), equalTo(5)); ObjectTypeDeclaration managerDataType = (ObjectTypeDeclaration) personType.get("Manager").getType(); assertThat(managerDataType.type(), equalTo("Person")); ArrayTypeDeclaration personsDataType = (ArrayTypeDeclaration) personType.get("Persons").getType(); assertThat(personsDataType.type(), equalTo("array")); assertThat(personsDataType.items().type(), equalTo("Person")); }
Example #6
Source File: ArrayTypeHandler.java From raml-java-tools with Apache License 2.0 | 4 votes |
public ArrayTypeHandler(String name, ArrayTypeDeclaration arrayTypeDeclaration) { this.name = name; this.typeDeclaration = arrayTypeDeclaration; }
Example #7
Source File: JaxbObjectExtension.java From raml-java-tools with Apache License 2.0 | 4 votes |
@Override public FieldSpec.Builder fieldBuilt(ObjectPluginContext objectPluginContext, TypeDeclaration property, FieldSpec.Builder fieldSpec, EventType eventType) { String namespace = property.xml() != null && property.xml().namespace() != null ? property.xml().namespace() : "##default"; String name = property.xml() != null && property.xml().name() != null ? property.xml().name() : property.name(); if (eventType == EventType.IMPLEMENTATION) { if (property.xml() != null && property.xml().wrapped() != null && property.xml().wrapped() && isArray(property)) { fieldSpec.addAnnotation( AnnotationSpec.builder(XmlElementWrapper.class).addMember("name", "$S", name).build() ); TypeName elementTypeName = objectPluginContext.dependentType(((ArrayTypeDeclaration)property).items()).getJavaName(EventType.IMPLEMENTATION); if (property.xml().attribute() != null && property.xml().attribute()) { fieldSpec.addAnnotation( AnnotationSpec.builder(XmlAttribute.class) .addMember("name", "$S", elementTypeName) .addMember("namespace", "$S", namespace) .build()); } else { fieldSpec.addAnnotation( AnnotationSpec.builder(XmlElement.class) .addMember("name", "$S", elementTypeName) .addMember("namespace", "$S", namespace) .build()); } } else { if (property.xml() != null && property.xml().attribute()) { fieldSpec.addAnnotation( AnnotationSpec.builder(XmlAttribute.class) .addMember("name", "$S", name) .addMember("namespace", "$S", namespace) .build()); } else { fieldSpec.addAnnotation( AnnotationSpec.builder(XmlElement.class) .addMember("name", "$S", name) .addMember("namespace", "$S", namespace) .build()); } } } return fieldSpec; }
Example #8
Source File: JaxbObjectExtension.java From raml-java-tools with Apache License 2.0 | 4 votes |
private boolean isArray(TypeDeclaration property) { return property instanceof ArrayTypeDeclaration; }
Example #9
Source File: ParameterImpl.java From raml-java-client-generator with Apache License 2.0 | 4 votes |
@Override public boolean isArray() { return typeDeclaration instanceof ArrayTypeDeclaration; }
Example #10
Source File: ArrayTypeInterpreter.java From springmvc-raml-plugin with Apache License 2.0 | 4 votes |
@Override public Set<Class<? extends TypeDeclaration>> getSupportedTypes() { return Collections.singleton(ArrayTypeDeclaration.class); }
Example #11
Source File: ArrayTypeHandlerTest.java From raml-java-tools with Apache License 2.0 | 3 votes |
@Test public void javaClassReferenceWithSomethingAsList() { when(arrayTypeHandlerPlugin.className(any(ArrayPluginContext.class), any(ArrayTypeDeclaration.class), (ClassName) eq(null), eq(EventType.INTERFACE))).thenReturn(ClassName.get("foo", "Something")); when(itemType.name()).thenReturn("Something"); when(itemType.type()).thenReturn("object"); ArrayTypeHandler handler = new ArrayTypeHandler("Something", arrayTypeDeclaration); TypeName tn = handler.javaClassReference(context, EventType.INTERFACE); assertEquals("foo.Something", tn.toString()); }
Example #12
Source File: RamlTypeHelper.java From springmvc-raml-plugin with Apache License 2.0 | 2 votes |
/** * Attempts to infer the type in the generic part of the declaration of the * type * * @param param * The parameter to inspect * @return The Class in the generic portrion of the typ */ public static boolean isArray(TypeDeclaration param) { return param instanceof ArrayTypeDeclaration; }