private static ArrayType getListOfMessageType(Type returnType, MetadataType outputType, MetadataType attributesOutputType) { return typeBuilder().arrayType() .of(new MessageMetadataTypeBuilder() .payload(outputType) .attributes(attributesOutputType) .build()) .with(returnType.getClassInformation()) .build(); }
public static ArrayType arrayOf(Class<? extends Collection> clazz, TypeBuilder itemType) { return TYPE_BUILDER.arrayType() .of(itemType) .with(new ClassInformationAnnotation(clazz)) .build(); }
private MetadataType adaptToListIfNecessary(MetadataType resolvedType, ParameterModel parameter, MetadataContext metadataContext) throws MetadataResolvingException { MetadataType inputType = parameter.getType(); if (!isCollection(inputType) || isNullType(resolvedType)) { return resolvedType; } return metadataContext.getTypeBuilder().arrayType() .with(new ClassInformationAnnotation(getType(inputType))) .of(resolvedType) .build(); } }
@Test public void getDataTypeFromList() { Class<List> listClass = List.class; Class<Integer> integerClass = Integer.class; ArrayTypeBuilder arrayTypeBuilder = BaseTypeBuilder.create(JAVA) .arrayType() .with(new ClassInformationAnnotation(listClass)); arrayTypeBuilder.of().numberType().integer(); CollectionDataType dataType = (CollectionDataType) toDataType(arrayTypeBuilder.build()); assertThat(dataType.getType(), is(equalTo(listClass))); assertThat(dataType.getItemDataType().getType(), is(equalTo(integerClass))); }
private MetadataType listOfString() { return TYPE_BUILDER.arrayType().of(TYPE_BUILDER.stringType()).with(new ClassInformationAnnotation(List.class)).build(); }
private MetadataType adaptToListIfNecessary(MetadataType resolvedType, Object key, MetadataContext metadataContext) throws MetadataResolvingException { MetadataType componentOutputType = ((HasOutputModel) component).getOutput().getType(); if (!isCollection(componentOutputType) || isVoid(resolvedType) || isNullType(resolvedType)) { return resolvedType; } MetadataType collectionValueType = ((ArrayType) componentOutputType).getType(); Class<?> collectionType = getCollectionType(collectionValueType); if (Message.class.equals(collectionType)) { MessageMetadataType message = (MessageMetadataType) collectionValueType; resolvedType = wrapInMessageType(resolvedType, key, metadataContext, message.getAttributesType()); } return metadataContext.getTypeBuilder().arrayType() .with(new ClassInformationAnnotation(getCollectionType(componentOutputType))) .of(resolvedType) .build(); }
return typeBuilder().arrayType() .of(itemType.asMetadataType()) .with(returnType.getClassInformation()) .build();
public ArrayTypeBuilder label(String label) { return with(new LabelAnnotation(label)); }
public ArrayTypeBuilder description(String content) { return with(new DescriptionAnnotation(content)); }
public ArrayTypeBuilder description(String lang, String content) { return with(new DescriptionAnnotation(content, lang)); }
public ArrayTypeBuilder id(String typeIdentifier) { return with(new TypeIdAnnotation(typeIdentifier)); }
public ArrayTypeBuilder boundary(Number minLength, Number maxLength) { return with(new LengthAnnotation(minLength, maxLength)); }
public ArrayTypeBuilder uniques() { return with(new UniquesItemsAnnotation()); }
@Override public TypeBuilder<?> handleClass(Class<?> clazz, List<Type> genericTypes, TypeHandlerManager typeHandlerManager, ParsingContext context, BaseTypeBuilder typeBuilder) { final Class<?> componentType = clazz.getComponentType(); final ArrayTypeBuilder arrayType = typeBuilder.arrayType().with(new ClassInformationAnnotation(clazz)); final Optional<TypeBuilder<?>> mayBeType = context.getTypeBuilder(componentType); if (mayBeType.isPresent()) { arrayType.of(mayBeType.get()); } else { typeHandlerManager.handle(componentType, context, arrayType.of()); } return arrayType; } }
@Override public TypeBuilder<?> handleClass(Class<?> clazz, List<Type> genericTypes, TypeHandlerManager typeHandlerManager, ParsingContext context, BaseTypeBuilder typeBuilder) { final Optional<Type> type = getGenericType(clazz, genericTypes); final ArrayTypeBuilder arrayType = typeBuilder.arrayType().with(new ClassInformationAnnotation(clazz, genericTypes)); context.addTypeBuilder(clazz, arrayType); if (type.isPresent()) { final Type arrayGenericType = type.get(); final Optional<TypeBuilder<?>> mayBeBuilder = context.getTypeBuilder(arrayGenericType); if (mayBeBuilder.isPresent()) { arrayType.of(mayBeBuilder.get()); } else { typeHandlerManager.handle(arrayGenericType, context, arrayType.of()); } } else { arrayType.of().anyType(); } return arrayType; }
private MetadataType adaptToListIfNecessary(MetadataType resolvedType, ParameterModel parameter, MetadataContext metadataContext) throws MetadataResolvingException { MetadataType inputType = parameter.getType(); if (!isCollection(inputType) || isNullType(resolvedType)) { return resolvedType; } return metadataContext.getTypeBuilder().arrayType() .with(new ClassInformationAnnotation(getType(inputType))) .of(resolvedType) .build(); } }
private static ArrayType getListOfMessageType(Type returnType, MetadataType outputType, MetadataType attributesOutputType) { return typeBuilder().arrayType() .of(new MessageMetadataTypeBuilder() .payload(outputType) .attributes(attributesOutputType) .build()) .with(returnType.getClassInformation()) .build(); }
private MetadataType adaptToListIfNecessary(MetadataType resolvedType, Object key, MetadataContext metadataContext) throws MetadataResolvingException { MetadataType componentOutputType = ((HasOutputModel) component).getOutput().getType(); if (!isCollection(componentOutputType) || isVoid(resolvedType) || isNullType(resolvedType)) { return resolvedType; } MetadataType collectionValueType = ((ArrayType) componentOutputType).getType(); Class<?> collectionType = getCollectionType(collectionValueType); if (Message.class.equals(collectionType)) { MessageMetadataType message = (MessageMetadataType) collectionValueType; resolvedType = wrapInMessageType(resolvedType, key, metadataContext, message.getAttributesType()); } return metadataContext.getTypeBuilder().arrayType() .with(new ClassInformationAnnotation(getCollectionType(componentOutputType))) .of(resolvedType) .build(); }
return typeBuilder().arrayType() .of(itemType.asMetadataType()) .with(returnType.getClassInformation()) .build();