private static boolean isListOfGeoResult(TypeInformation<?> returnType) { if (!returnType.getType().equals(List.class)) { return false; } TypeInformation<?> componentType = returnType.getComponentType(); return componentType != null && GeoResult.class.equals(componentType.getType()); } }
private boolean isStreamOfGeoResult() { if (!ReactiveWrappers.supports(returnType.getType())) { return false; } TypeInformation<?> componentType = returnType.getComponentType(); return componentType != null && GeoResult.class.equals(componentType.getType()); } }
/** * Populates the given {@link Collection sink} with converted values from the given {@link Collection source}. * * @param source the collection to create a {@link Collection} for, must not be {@literal null}. * @param type the {@link TypeInformation} to consider or {@literal null} if unknown. * @param sink the {@link Collection} to write to. * @return */ @SuppressWarnings("unchecked") private List<Object> writeCollectionInternal(Collection<?> source, @Nullable TypeInformation<?> type, Collection<?> sink) { TypeInformation<?> componentType = null; List<Object> collection = sink instanceof List ? (List<Object>) sink : new ArrayList<>(sink); if (type != null) { componentType = type.getComponentType(); } for (Object element : source) { Class<?> elementType = element == null ? null : element.getClass(); if (elementType == null || conversions.isSimpleType(elementType)) { collection.add(getPotentiallyConvertedSimpleWrite(element)); } else if (element instanceof Collection || elementType.isArray()) { collection.add(writeCollectionInternal(asCollection(element), componentType, new BasicDBList())); } else { Document document = new Document(); writeInternal(element, document, componentType); collection.add(document); } } return collection; }
TypeInformation<?> keyType = type.getComponentType(); TypeInformation<?> valueType = type.getMapValueType();
TypeInformation<?> componentType = targetType.getComponentType() != null // ? targetType.getComponentType() // : ClassTypeInformation.OBJECT; Class<?> rawComponentType = componentType.getType();
private static boolean isListOfGeoResult(TypeInformation<?> returnType) { if (!returnType.getType().equals(List.class)) { return false; } TypeInformation<?> componentType = returnType.getComponentType(); return componentType != null && GeoResult.class.equals(componentType.getType()); } }
private boolean isStreamOfGeoResult() { if (!ReactiveWrappers.supports(returnType.getType())) { return false; } TypeInformation<?> componentType = returnType.getComponentType(); return componentType != null && GeoResult.class.equals(componentType.getType()); } }
/** * Populates the given {@link Collection sink} with converted values from the given {@link Collection source}. * * @param source the collection to create a {@link Collection} for, must not be {@literal null}. * @param type the {@link TypeInformation} to consider or {@literal null} if unknown. * @param sink the {@link Collection} to write to. * @return */ @SuppressWarnings("unchecked") private List<Object> writeCollectionInternal(Collection<?> source, @Nullable TypeInformation<?> type, Collection<?> sink) { TypeInformation<?> componentType = null; List<Object> collection = sink instanceof List ? (List<Object>) sink : new ArrayList<>(sink); if (type != null) { componentType = type.getComponentType(); } for (Object element : source) { Class<?> elementType = element == null ? null : element.getClass(); if (elementType == null || conversions.isSimpleType(elementType)) { collection.add(getPotentiallyConvertedSimpleWrite(element)); } else if (element instanceof Collection || elementType.isArray()) { collection.add(writeCollectionInternal(asCollection(element), componentType, new BasicDBList())); } else { Document document = new Document(); writeInternal(element, document, componentType); collection.add(document); } } return collection; }
/** * Handles the given {@link JsonNode} by treating it as {@link ArrayNode} and the given source value as * {@link Collection}-like value. Looks up the actual type to handle from the potentially available first element, * falling back to component type lookup on the given type. * * @param node must not be {@literal null}. * @param source must not be {@literal null}. * @param mapper must not be {@literal null}. * @param collectionType must not be {@literal null}. * @return * @throws Exception */ private boolean handleArray(JsonNode node, Object source, ObjectMapper mapper, TypeInformation<?> collectionType) { Collection<Object> collection = ifCollection(source); if (collection == null) { return false; } return execute(() -> handleArrayNode((ArrayNode) node, collection, mapper, collectionType.getComponentType())); }
Class<?> keyType = typeOrObject(type.getComponentType()); TypeInformation<?> valueType = type.getMapValueType();
TypeInformation<?> keyType = type.getComponentType(); TypeInformation<?> valueType = type.getMapValueType();
TypeInformation<?> componentType = targetType.getComponentType() != null // ? targetType.getComponentType() // : ClassTypeInformation.OBJECT; Class<?> rawComponentType = componentType.getType();
private TypeInformation<?> getNonNullComponentType(final TypeInformation<?> type) { final TypeInformation<?> compType = type.getComponentType(); return compType != null ? compType : ClassTypeInformation.OBJECT; }
private TypeInformation<?> getNonNullComponentType(final TypeInformation<?> type) { final TypeInformation<?> compType = type.getComponentType(); return compType != null ? compType : ClassTypeInformation.OBJECT; }
private Class<?> getCollectionClass(TypeInformation<?> typeInformation, Collection<?> obj) { if (typeInformation != null && typeInformation.getComponentType() != null) { return typeInformation.getComponentType().getType(); } if (obj.isEmpty()) { return Object.class; } return obj.iterator().next().getClass(); }
private List<Object> convertCollection(final Collection<?> source, final TypeInformation<?> type) { Assert.notNull(source, "Given collection must not be null!"); Assert.notNull(type, "Given type must not be null!"); TypeInformation<?> componentType = type.getComponentType(); return source.stream().map(element -> getValueToWrite(element, componentType)).collect(Collectors.toList()); }
private <R> R convertCollection(final Collection source, final TypeInformation<?> propertyType) { Class<?> collectionClass = propertyType.getType(); TypeInformation<?> elementType = propertyType.getComponentType(); Class<?> elementClass = elementType == null ? null : elementType.getType(); Collection<Object> items = collectionClass.isArray() ? new ArrayList<>() : CollectionFactory.createCollection(collectionClass, elementClass, source.size()); source.forEach(item -> items.add(readValue(item, elementType))); return (R) convertIfNeeded(items, propertyType.getType()); }
private void collectWithCollections(final PropertyPath propertyPath) { propertyPath.stream().map(property -> { return property.isCollection() ? property.getTypeInformation().getComponentType() : property.getTypeInformation(); }).map(type -> { return context.getPersistentEntity(type); }).filter(entity -> { return entity != null; }).map(entity -> { return AqlUtils.buildCollectionName(entity.getCollection()); }).forEach(withCollections::add); }
public Class<?> getComponentType() { if (!isMap() && !isCollectionLike()) { return null; } TypeInformation<?> componentType = information.getComponentType(); return componentType == null ? null : componentType.getType(); }
private static TypeInformation<?> detectDomainType(TypeInformation<?> source) { if (source.getTypeArguments().isEmpty()) { return source; } TypeInformation<?> actualType = source.getActualType(); if (source != actualType) { return detectDomainType(actualType); } if (source instanceof Iterable) { return source; } return detectDomainType(source.getComponentType()); }