@Override public Map<String, List<RamlFormParameter>> getFormParameters() { if (formParameters == null) { this.formParameters = ((ObjectTypeDeclaration) mimeType).properties().stream() .collect(Collectors.toMap(this::getName, this::getList)); } return this.formParameters; }
private static Set<String> pullNames(ObjectTypeDeclaration extending) { return FluentIterable.from(extending.properties()).transform(new Function<TypeDeclaration, String>() { @Nullable @Override public String apply(@Nullable TypeDeclaration input) { return input.name(); } }).toSet(); }
private static List<V10GProperty> getProperties(final TypeDeclaration input, final V10TypeRegistry registry) { if (input instanceof ObjectTypeDeclaration) { ObjectTypeDeclaration otd = (ObjectTypeDeclaration) input; return Lists.transform(otd.properties(), new Function<TypeDeclaration, V10GProperty>() { @Nullable @Override public V10GProperty apply(@Nullable TypeDeclaration declaration) { return new V10GProperty(declaration, registry.fetchType(declaration.type(), declaration)); } }); } else { return Collections.emptyList(); } }
private void buildLooksLike(TypeSpec.Builder builder, TypeDeclaration typeDeclaration) { String name = Names.methodName("looksLike", typeDeclaration.name()); MethodSpec.Builder spec = MethodSpec.methodBuilder(name).addParameter(ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), ClassName.get(Object.class)), "map"); if (typeDeclaration instanceof ObjectTypeDeclaration) { ObjectTypeDeclaration otd = (ObjectTypeDeclaration) typeDeclaration; List<String> names = Lists.transform(otd.properties(), new Function<TypeDeclaration, String>() { @Nullable @Override public String apply(@Nullable TypeDeclaration input) { return "\"" + input.name() + "\""; } }); spec.addStatement("return map.keySet().containsAll($T.asList($L))", Arrays.class, Joiner.on(",").join(names)); } spec.addModifiers(Modifier.PRIVATE).returns(TypeName.BOOLEAN); builder.addMethod(spec.build()); }
private void buildLooksLike(TypeSpec.Builder builder, TypeDeclaration typeDeclaration) { String name = Names.methodName("looksLike", typeDeclaration.name()); MethodSpec.Builder spec = MethodSpec.methodBuilder(name).addParameter(ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), ClassName.get(Object.class)), "map"); if (typeDeclaration instanceof ObjectTypeDeclaration) { ObjectTypeDeclaration otd = (ObjectTypeDeclaration) typeDeclaration; List<String> names = Lists.transform(otd.properties(), new Function<TypeDeclaration, String>() { @Nullable @Override public String apply(@Nullable TypeDeclaration input) { return "\"" + input.name() + "\""; } }); spec.addStatement("return map.keySet().containsAll($T.asList($L))", Arrays.class, Joiner.on(",").join(names)); } spec.addModifiers(Modifier.PRIVATE).returns(TypeName.BOOLEAN); builder.addMethod(spec.build()); }
private void buildLooksLike(TypeSpec.Builder builder, TypeDeclaration typeDeclaration) { String name = Names.methodName("looksLike", typeDeclaration.name()); MethodSpec.Builder spec = MethodSpec.methodBuilder(name).addParameter(ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class), ClassName.get(Object.class)), "map"); if (typeDeclaration instanceof ObjectTypeDeclaration) { ObjectTypeDeclaration otd = (ObjectTypeDeclaration) typeDeclaration; List<String> names = Lists.transform(otd.properties(), new Function<TypeDeclaration, String>() { @Nullable @Override public String apply(@Nullable TypeDeclaration input) { return "\"" + input.name() + "\""; } }); spec.addStatement("return map.keySet().containsAll($T.asList($L))", Arrays.class, Strings.join(names, ",")); } spec.addModifiers(Modifier.PRIVATE).returns(TypeName.BOOLEAN); builder.addMethod(spec.build()); }
return extendedObject.properties().size() < extendingObject.properties().size();
private CodeBlock.Builder withProperties(TypeName newSpec, ObjectTypeDeclaration object) { List<TypeDeclaration> properties = FluentIterable.from(object.properties()).filter(new Predicate<TypeDeclaration>() { @Override public boolean apply(@Nullable TypeDeclaration property) { return property != null && EcmaPattern.isSlashedPattern(property.name()) && ! EcmaPattern.fromString(property.name()).asJavaPattern().isEmpty(); } }).toList(); if ( properties.size() == 0) { return CodeBlock.of("new $T()", newSpec).toBuilder(); } CodeBlock.Builder cb = CodeBlock.builder().beginControlFlow("new $T()", newSpec).beginControlFlow(""); for (TypeDeclaration typeDeclaration : object.properties()) { cb.addStatement("addAcceptedPattern($T.compile($S))", Pattern.class, EcmaPattern.fromString(typeDeclaration.name()).asJavaPattern()); } return cb.endControlFlow().endControlFlow(); }
return extendedObject.properties().size() < extendingObject.properties().size();
for (TypeDeclaration declaration : obj.properties()) {
for (TypeDeclaration propertyDeclaration : objectTypeDeclaration.properties()) {
private void createParamteter(MethodSpec.Builder methodSpec, GRequest gRequest, GMethod gMethod) { if ("application/x-www-form-urlencoded".equals(gRequest.mediaType())) { if (gRequest.type().implementation() instanceof ObjectTypeDeclaration) { ObjectTypeDeclaration object = (ObjectTypeDeclaration) gRequest.type().implementation(); for (TypeDeclaration typeDeclaration : object.properties()) { V10GType type = build.fetchType(Names.javaTypeName((Resource) gMethod.resource().implementation(), (Method) gMethod.implementation(), typeDeclaration), typeDeclaration); methodSpec.addParameter(ParameterSpec .builder(type.defaultJavaTypeName(build.getModelPackage()), typeDeclaration.name()) .addAnnotation(AnnotationSpec.builder(FormParam.class).addMember("value", "$S", typeDeclaration.name()).build()) .build()); } } return; } if (gRequest.type().name().equals("any") && "application/octet-stream".equals(gRequest.mediaType())) { TypeName typeName = ClassName.get(InputStream.class); methodSpec.addParameter(ParameterSpec.builder(typeName, "entity").build()); } else { TypeName typeName = gRequest.type().defaultJavaTypeName(build.getModelPackage()); methodSpec.addParameter(ParameterSpec.builder(typeName, "entity").build()); } }
for (TypeDeclaration propertyDeclaration : objectTypeDeclaration.properties()) {
for (TypeDeclaration property : declaration.properties()) {
for (TypeDeclaration objectProperty : objectType.properties()) {
@Override public TypeSpec.Builder classCreated(ObjectPluginContext objectPluginContext, ObjectTypeDeclaration obj, TypeSpec.Builder typeSpec, EventType eventType) { if (eventType != EventType.IMPLEMENTATION) { return typeSpec; } typeSpec.addAnnotation(AnnotationSpec.builder(JsonInclude.class) .addMember("value", "$T.$L", JsonInclude.Include.class, "NON_NULL").build()); if (obj.discriminatorValue() != null) { typeSpec.addAnnotation(AnnotationSpec.builder(JsonTypeName.class) .addMember("value", "$S", obj.discriminatorValue()).build()); } AnnotationSpec.Builder builder = AnnotationSpec.builder(JsonPropertyOrder.class); for (TypeDeclaration declaration : obj.properties()) { if (EcmaPattern.isSlashedPattern(declaration.name())) { continue; } builder.addMember("value", "$S", declaration.name()); } typeSpec.addAnnotation(builder.build()); return typeSpec; }
@Override public TypeSpec.Builder classCreated(ObjectPluginContext objectPluginContext, ObjectTypeDeclaration obj, TypeSpec.Builder typeSpec, EventType eventType) { if (eventType != EventType.IMPLEMENTATION) { return typeSpec; } typeSpec.addAnnotation(AnnotationSpec.builder(JsonInclude.class) .addMember("value", "$T.$L", JsonInclude.Include.class, "NON_NULL").build()); if (obj.discriminatorValue() != null) { typeSpec.addAnnotation(AnnotationSpec.builder(JsonTypeName.class) .addMember("value", "$S", obj.discriminatorValue()).build()); } AnnotationSpec.Builder builder = AnnotationSpec.builder(JsonPropertyOrder.class); for (TypeDeclaration declaration : obj.properties()) { if (EcmaPattern.isSlashedPattern(declaration.name())) { continue; } builder.addMember("value", "$S", declaration.name()); } typeSpec.addAnnotation(builder.build()); return typeSpec; }
for (TypeDeclaration formParameter : formParameters.properties()) {