if (typeToUse.isCollectionLike() && bson instanceof List) { return (S) readCollectionOrArray(typeToUse, (List<?>) bson, path);
TypeInformation<?> type = prop.getTypeInformation(); if (valueType.isCollectionLike()) { List<Object> collectionInternal = createCollection(asCollection(obj), prop); accessor.put(prop, collectionInternal);
if (typeInformation.isCollectionLike()) {
JsonSchemaProperty with(TypeInformation<?> type, String reference) { if (type.isCollectionLike()) { if (Set.class.equals(type.getType())) { this.uniqueItems = true; } this.type = toJsonSchemaType(type); this.items = Collections.singletonMap("$ref", reference); return this; } else { this.reference = reference; return this; } } }
/** * Configures the {@link JsonSchemaProperty} to reflect the given type. * * @param type must not be {@literal null}. * @return */ public JsonSchemaProperty with(TypeInformation<?> type) { Assert.notNull(type, "Type must not be null!"); this.type = toJsonSchemaType(type); if (isDate(type)) { return withFormat(JsonSchemaFormat.DATE_TIME); } if (type.isCollectionLike()) { if (Set.class.equals(type.getType())) { this.uniqueItems = true; } this.items = Collections.singletonMap("type", toJsonSchemaType(type.getActualType())); } return this; }
/** * Turns the given {@link TypeInformation} into a JSON Schema type string. * * @param typeInformation * @return * @see <a href= * "http://json-schema.org/latest/json-schema-core.html#anchor8">http://json-schema.org/latest/json-schema-core.html#anchor8</a> */ private static String toJsonSchemaType(TypeInformation<?> typeInformation) { Class<?> type = typeInformation.getType(); if (type == null) { return null; } else if (typeInformation.isCollectionLike()) { return "array"; } else if (Boolean.class.equals(type) || boolean.class.equals(type)) { return "boolean"; } else if (String.class.equals(type) || isDate(typeInformation) || type.isEnum()) { return "string"; } else if (INTEGER_TYPES.contains(type)) { return "integer"; } else if (ClassUtils.isAssignable(Number.class, type)) { return "number"; } else { return "object"; } }
private static FilterBuilder resolveMatchingContainsFilterBuilder(Part part, Class<?> entityType, BooleanOperator booleanOperator) { boolean usePropertyComparison = !part.getProperty().getTypeInformation().isCollectionLike(); if (usePropertyComparison) { return new PropertyComparisonBuilder(part, booleanOperator, entityType); } return new ContainsComparisonBuilder(part, booleanOperator, entityType); } }
if (typeToUse.isCollectionLike() && bson instanceof List) { return (S) readCollectionOrArray(typeToUse, (List<?>) bson, path);
@Override public boolean isCollectionLike() { return information.isCollectionLike(); }
public boolean isCollectionLike() { return information.isCollectionLike(); }
TypeInformation<?> type = prop.getTypeInformation(); if (valueType.isCollectionLike()) { List<Object> collectionInternal = createCollection(asCollection(obj), prop); accessor.put(prop, collectionInternal);
JsonSchemaProperty with(TypeInformation<?> type, String reference) { if (type.isCollectionLike()) { if (Set.class.equals(type.getType())) { this.uniqueItems = true; } this.type = toJsonSchemaType(type); this.items = Collections.singletonMap("$ref", reference); return this; } else { this.reference = reference; return this; } } }
@Nullable private DataType getUserDataType(TypeInformation<?> property, @Nullable DataType elementType) { if (property.isCollectionLike()) { if (List.class.isAssignableFrom(property.getType())) { return DataType.list(elementType); } if (Set.class.isAssignableFrom(property.getType())) { return DataType.set(elementType); } } return !(property.isCollectionLike() || property.isMap()) ? elementType : null; }
@Override public <T> T convertOnRead(Object val, EmbeddedType embeddedType, TypeInformation targetTypeInformation) { TypeInformation componentTypeInformation; Class collectionType = null; if (targetTypeInformation.isCollectionLike()) { componentTypeInformation = targetTypeInformation.getComponentType(); collectionType = targetTypeInformation.getType(); } else { componentTypeInformation = targetTypeInformation; } return convertOnRead(val, embeddedType, collectionType, componentTypeInformation); }
@Override public <T> T convertOnRead(Object val, EmbeddedType embeddedType, TypeInformation targetTypeInformation) { TypeInformation componentTypeInformation; Class collectionType = null; if (targetTypeInformation.isCollectionLike()) { componentTypeInformation = targetTypeInformation.getComponentType(); collectionType = targetTypeInformation.getType(); } else { componentTypeInformation = targetTypeInformation; } return convertOnRead(val, embeddedType, collectionType, componentTypeInformation); }
private static boolean isEntity(java.lang.reflect.Field field) { TypeInformation typeInformation = ClassTypeInformation.from(field.getType()); TypeInformation<?> actualType = typeInformation.getActualType(); boolean isComplexType = actualType == null ? false : !SIMPLE_TYPE_HOLDER.isSimpleType(actualType.getType()); return isComplexType && !actualType.isCollectionLike() && !Map.class.isAssignableFrom(typeInformation.getType()); }
public Iterable<? extends TypeInformation<?>> getPersistentEntityType() { List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(); TypeInformation<?> type = getTypeInformation(); if (isEntity()) { result.add(type); } if (type.isCollectionLike() || isMap()) { TypeInformation<?> nestedType = getTypeInformationIfNotSimpleType(getTypeInformation().getActualType()); if (nestedType != null) { result.add(nestedType); } } return result; }
private static FilterBuilder resolveMatchingContainsFilterBuilder(Part part, Class<?> entityType, BooleanOperator booleanOperator) { boolean usePropertyComparison = !part.getProperty().getTypeInformation().isCollectionLike(); if (usePropertyComparison) { return new PropertyComparisonBuilder(part, booleanOperator, entityType); } return new ContainsComparisonBuilder(part, booleanOperator, entityType); } }
private Object getNonSimpleValueToWrite(Object value, TypeInformation<?> type) { TypeInformation<?> valueType = ClassTypeInformation.from(value.getClass()); if (valueType.isCollectionLike()) { return convertCollection(asCollection(value), type); } if (valueType.isMap()) { return convertMap(asMap(value), type); } Class<?> basicTargetType = conversions.getCustomWriteTarget(value.getClass()); if (basicTargetType != null) { return conversionService.convert(value, basicTargetType); } return convertCustomType(value, valueType); }
private static Class<?> getCollectionType(TypeInformation<?> type) { if (type.getType().isInterface()) { return type.getType(); } if (ClassTypeInformation.LIST.isAssignableFrom(type)) { return ClassTypeInformation.LIST.getType(); } if (ClassTypeInformation.SET.isAssignableFrom(type)) { return ClassTypeInformation.SET.getType(); } if (!type.isCollectionLike()) { return ClassTypeInformation.LIST.getType(); } return type.getType(); }