@Override public Parameter transform(final Context context, final MimeType src, final TransformationContext ctx) { if (SUPPORTED_MIME_TYPES.contains(src.getType())) { final Type type = Type.typeBuilder().namespace(ctx.getNamespace()).qualifier(String.class.getSimpleName()).build(); return Parameter.builder()// .name(String.class.getSimpleName())// .parameterType(ParameterType.BODY)// .qualifier(String.class.getSimpleName())// .type(type)// .build(); } return null; } }
/** * A hook method that determines the c to use for a new {@link OneOfAttribute}. * <p/> * Called by {@link #createOneOfAttribute(APINamespace, String, Collection)} to make that decision. Subclasses may * override to fine-tune the {@code Type} to use. * * @param oneOfAlternativeFields The {@code JFieldVars} that Ignored by this implementation. May be used by * sub-classes to find the best common super-Type of all the alternatives of * the new {@link OneOfAttribute} * @return The {@code Type} to use. This implementation always returns a new {@code Type} that represents * {@link Object}. */ protected Type determineOneOfAttributeType(final Collection<JFieldVar> oneOfAlternativeFields) { return Type.typeBuilder() .name("Object ") .qualifier(Object.class.getName()) .build(); }
/** * @param namespace a java package abstraction where to look for type parameters * @param metaType a parameter type 'container' * @return a list of param types adjusted into particular package context */ public static List<Type> resolveTypeParams(final com.sap.cloud.yaas.servicegenerator.model.APINamespace namespace, final JType metaType) { final ImmutableList.Builder<Type> typeParams = ImmutableList.builder(); if (metaType instanceof JClass) { for (final JType type : ((JClass) metaType).getTypeParameters()) { final Type paramModel = Type.typeBuilder()// .namespace(namespace)// .name(type.erasure().name())// .qualifier(type.erasure().name())// .typeParameters(resolveTypeParams(namespace, type))// .build(); typeParams.add(paramModel); } } return typeParams.build(); }
.name(TypeUtils.getErasureType(singleField.type())) .typeParameters(TypeUtils.resolveTypeParams(namespace, metaType)) .qualifier(TypeUtils.getErasureType(singleField.type())) .source(jType) .build(); .name(TypeUtils.getErasureType(singleField.type())) .typeParameters(TypeUtils.resolveTypeParams(namespace, metaType)) .qualifier(TypeUtils.getErasureType(singleField.type())) .source(jType) .build();
final Type argumentType = Type.typeBuilder()// .qualifier(toCapitalize(source)) // .name("A " + metaType + " parameter of metaType " + toCapitalize(source))// .build();
@Override public ArrayDto transform(final Context context, final JClass input, final APINamespace namespace) { final JClass elementType = resolveElementClass(input); final ArrayDtoBuilder builder = ArrayDto.arrayDtoBuilder() .schemaName(schemaNameStrategy.getSchemaNameForClass(input)) .namespace(namespace) .name("Generated List for " + input.name()) .source(input) .qualifier(input.name()); if (isOfEnum(elementType)) { builder.typeParameters(Collections.singletonList(asEnumeration(elementType, namespace))); } else if (elementType instanceof JDefinedClass) { builder.typeParameters( Collections.singletonList(dtoTransformer.transform(context, (JDefinedClass) elementType, namespace))); } else { final Type refType = Type.typeBuilder().name(elementType.name()) .qualifier(elementType.name()).build(); builder.typeParameters(Collections.singletonList(refType)); } return builder.build(); }
private Type createTypeModel(final APINamespace namespace, final String name) { return Type.typeBuilder().namespace(namespace).name(name).qualifier(name).build(); }
private Type createTypeModel(final APINamespace namespace, final JType clazz) { return Type.typeBuilder()// .namespace(namespace)// .name(TypeUtils.getErasureType(clazz))// .qualifier(TypeUtils.getErasureType(clazz))// .typeParameters(TypeUtils.resolveTypeParams(namespace, clazz))// .build(); }