/** * Converts the given value with the underlying {@link MongoWriter}. * * @param value can be {@literal null}. * @param typeInformation can be {@literal null}. * @return */ @Nullable private Object getConvertedValue(Object value, @Nullable TypeInformation<?> typeInformation) { return writer.convertToMongoType(value, typeInformation == null ? null : typeInformation.getActualType()); }
private TypeInformation<?> getTypeHintForEntity(@Nullable Object source, MongoPersistentEntity<?> entity) { TypeInformation<?> info = entity.getTypeInformation(); Class<?> type = info.getActualType().getType(); if (source == null || type.isInterface() || java.lang.reflect.Modifier.isAbstract(type.getModifiers())) { return info; } if (source instanceof Collection) { return NESTED_DOCUMENT; } if (!type.equals(source.getClass())) { return info; } return NESTED_DOCUMENT; }
/** * Adds custom type information to the given {@link Document} if necessary. That is if the value is not the same as * the one given. This is usually the case if you store a subtype of the actual declared type of the property. * * @param type * @param value must not be {@literal null}. * @param bson must not be {@literal null}. */ protected void addCustomTypeKeyIfNecessary(@Nullable TypeInformation<?> type, Object value, Bson bson) { Class<?> reference = type != null ? type.getActualType().getType() : Object.class; Class<?> valueType = ClassUtils.getUserClass(value.getClass()); boolean notTheSameClass = !valueType.equals(reference); if (notTheSameClass) { typeMapper.writeType(valueType, bson); } }
: persistentProperty.getTypeInformation().getActualType(); indexes.addAll(doResolveIndexesFor(keyspace, currentPath + "." + entry.getKey(), typeToUse.getActualType(), persistentProperty, entry.getValue())); TypeInformation<?> typeToUse = updateTypeHintForActualValue(typeHint, listValue); indexes.addAll( doResolveIndexesFor(keyspace, currentPath, typeToUse.getActualType(), persistentProperty, listValue)); || persistentProperty.getTypeInformation().getActualType().equals(ClassTypeInformation.OBJECT)) { doResolveIndexesFor(keyspace, currentPath, typeHint.getActualType(), persistentProperty, propertyValue)); } else { indexes.addAll(resolveIndex(keyspace, currentPath, persistentProperty, propertyValue));
private void guradAndPotentiallyAddIndexForProperty(MongoPersistentProperty persistentProperty, String dotPath, Path path, String collection, List<IndexDefinitionHolder> indexes, CycleGuard guard) { String propertyDotPath = (StringUtils.hasText(dotPath) ? dotPath + "." : "") + persistentProperty.getFieldName(); Path propertyPath = path.append(persistentProperty); guard.protect(persistentProperty, propertyPath); if (persistentProperty.isEntity()) { try { indexes.addAll(resolveIndexForClass(persistentProperty.getTypeInformation().getActualType(), propertyDotPath, propertyPath, collection, guard)); } catch (CyclicPropertyReferenceException e) { LOGGER.info(e.getMessage()); } } IndexDefinitionHolder indexDefinitionHolder = createIndexDefinitionHolderForProperty(propertyDotPath, collection, persistentProperty); if (indexDefinitionHolder != null) { indexes.add(indexDefinitionHolder); } }
private void potentiallyAddIndexForProperty(MongoPersistentEntity<?> root, MongoPersistentProperty persistentProperty, List<IndexDefinitionHolder> indexes, CycleGuard guard) { try { if (persistentProperty.isEntity()) { indexes.addAll(resolveIndexForClass(persistentProperty.getTypeInformation().getActualType(), persistentProperty.getFieldName(), Path.of(persistentProperty), root.getCollection(), guard)); } IndexDefinitionHolder indexDefinitionHolder = createIndexDefinitionHolderForProperty( persistentProperty.getFieldName(), root.getCollection(), persistentProperty); if (indexDefinitionHolder != null) { indexes.add(indexDefinitionHolder); } } catch (CyclicPropertyReferenceException e) { LOGGER.info(e.getMessage()); } }
persistentProperty.getTypeInformation().getActualType(), sink);
typeInformation.getRequiredComponentType().getActualType().getType(), source.getBucket()); && !conversionService.canConvert(byte[].class, typeInformation.getActualType().getType())) { typeInformation.getActualType()); return sourceBytes == null ? fromBytes(sourceBytes, typeInformation.getActualType().getType()) : source.getId();
/** * Converts the given value with the underlying {@link MongoWriter}. * * @param value can be {@literal null}. * @param typeInformation can be {@literal null}. * @return */ @Nullable private Object getConvertedValue(Object value, @Nullable TypeInformation<?> typeInformation) { return writer.convertToMongoType(value, typeInformation == null ? null : typeInformation.getActualType()); }
/** * Creates a new {@link Item} for the given {@link TypeInformation} and properties. * * @param type must not be {@literal null}. * @param properties must not be {@literal null}. */ public Item(TypeInformation<?> type, Collection<AbstractJsonSchemaProperty<?>> properties) { this.type = toJsonSchemaType(type.getActualType()); this.properties = new PropertiesContainer(properties); }
: (targetProperty.isMap() ? (targetProperty.getTypeInformation().getMapValueType() != null ? targetProperty.getTypeInformation().getRequiredMapValueType() : ClassTypeInformation.OBJECT) : targetProperty.getTypeInformation().getActualType()); .getInverse().getTypeInformation().getRequiredComponentType().getActualType()); : Collections.<Object> singleton(pUpdate.getValue()); writeCollection(entity.getKeySpace(), pUpdate.getPropertyPath(), collection, targetProperty.getTypeInformation().getActualType(), sink); } else if (targetProperty.isMap()) {
private TypeInformation<?> getTypeHintForEntity(@Nullable Object source, MongoPersistentEntity<?> entity) { TypeInformation<?> info = entity.getTypeInformation(); Class<?> type = info.getActualType().getType(); if (source == null || type.isInterface() || java.lang.reflect.Modifier.isAbstract(type.getModifiers())) { return info; } if (source instanceof Collection) { return NESTED_DOCUMENT; } if (!type.equals(source.getClass())) { return info; } return NESTED_DOCUMENT; }
association.getInverse().getTypeInformation().getRequiredComponentType().getActualType());
static String typeKey(TypeInformation<?> type) { return StringUtils.uncapitalize(type.getActualType().getType().getSimpleName()); } }
/** * Adds custom type information to the given {@link Document} if necessary. That is if the value is not the same as * the one given. This is usually the case if you store a subtype of the actual declared type of the property. * * @param type * @param value must not be {@literal null}. * @param bson must not be {@literal null}. */ protected void addCustomTypeKeyIfNecessary(@Nullable TypeInformation<?> type, Object value, Bson bson) { Class<?> reference = type != null ? type.getActualType().getType() : Object.class; Class<?> valueType = ClassUtils.getUserClass(value.getClass()); boolean notTheSameClass = !valueType.equals(reference); if (notTheSameClass) { typeMapper.writeType(valueType, bson); } }
/** * 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; }
private void guradAndPotentiallyAddIndexForProperty(MongoPersistentProperty persistentProperty, String dotPath, Path path, String collection, List<IndexDefinitionHolder> indexes, CycleGuard guard) { String propertyDotPath = (StringUtils.hasText(dotPath) ? dotPath + "." : "") + persistentProperty.getFieldName(); Path propertyPath = path.append(persistentProperty); guard.protect(persistentProperty, propertyPath); if (persistentProperty.isEntity()) { try { indexes.addAll(resolveIndexForClass(persistentProperty.getTypeInformation().getActualType(), propertyDotPath, propertyPath, collection, guard)); } catch (CyclicPropertyReferenceException e) { LOGGER.info(e.getMessage()); } } IndexDefinitionHolder indexDefinitionHolder = createIndexDefinitionHolderForProperty(propertyDotPath, collection, persistentProperty); if (indexDefinitionHolder != null) { indexes.add(indexDefinitionHolder); } }
private void potentiallyAddIndexForProperty(MongoPersistentEntity<?> root, MongoPersistentProperty persistentProperty, List<IndexDefinitionHolder> indexes, CycleGuard guard) { try { if (persistentProperty.isEntity()) { indexes.addAll(resolveIndexForClass(persistentProperty.getTypeInformation().getActualType(), persistentProperty.getFieldName(), Path.of(persistentProperty), root.getCollection(), guard)); } IndexDefinitionHolder indexDefinitionHolder = createIndexDefinitionHolderForProperty( persistentProperty.getFieldName(), root.getCollection(), persistentProperty); if (indexDefinitionHolder != null) { indexes.add(indexDefinitionHolder); } } catch (CyclicPropertyReferenceException e) { LOGGER.info(e.getMessage()); } }
/** * @param invoker * @param request * @param method * @param pageable * @return */ private Optional<Object> executeQueryMethod(final RepositoryInvoker invoker, @RequestParam MultiValueMap<String, Object> parameters, Method method, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler) { MultiValueMap<String, Object> result = new LinkedMultiValueMap<String, Object>(parameters); MethodParameters methodParameters = new MethodParameters(method, new AnnotationAttribute(Param.class)); List<MethodParameter> parameterList = methodParameters.getParameters(); List<TypeInformation<?>> parameterTypeInformations = ClassTypeInformation.from(method.getDeclaringClass()) .getParameterTypes(method); for (Entry<String, List<Object>> entry : parameters.entrySet()) { MethodParameter parameter = methodParameters.getParameter(entry.getKey()); if (parameter == null) { continue; } int parameterIndex = parameterList.indexOf(parameter); TypeInformation<?> domainType = parameterTypeInformations.get(parameterIndex).getActualType(); ResourceMetadata metadata = mappings.getMetadataFor(domainType.getType()); if (metadata != null && metadata.isExported()) { result.put(parameter.getParameterName(), prepareUris(entry.getValue())); } } return invoker.invokeQueryMethod(method, result, pageable.getPageable(), sort); }
TypeInformation<?> actualPropertyType = propertyType.getActualType(); Class<?> rawPropertyType = propertyType.getType();