org.springframework.data.mapping.PreferredConstructor.Parameter Java Examples
The following examples show how to use
org.springframework.data.mapping.PreferredConstructor.Parameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MappingVaultConverter.java From spring-vault with Apache License 2.0 | 6 votes |
private ParameterValueProvider<VaultPersistentProperty> getParameterProvider(VaultPersistentEntity<?> entity, SecretDocument source) { VaultPropertyValueProvider provider = new VaultPropertyValueProvider(source); PersistentEntityParameterValueProvider<VaultPersistentProperty> parameterProvider = new PersistentEntityParameterValueProvider<>( entity, provider, source); return new ParameterValueProvider<VaultPersistentProperty>() { @Nullable @Override public <T> T getParameterValue(Parameter<T, VaultPersistentProperty> parameter) { Object value = parameterProvider.getParameterValue(parameter); return value != null ? readValue(value, parameter.getType()) : null; } }; }
Example #2
Source File: TypicalEntityReaderBenchmark.java From spring-data-dev-tools with Apache License 2.0 | 4 votes |
@Override public <T> T getParameterValue(Parameter<T, MyPersistentProperty> parameter) { return null; }
Example #3
Source File: TypicalEntityReaderBenchmark.java From spring-data-dev-tools with Apache License 2.0 | 4 votes |
/** * Typical code used to read entities in {@link org.springframework.data.convert.EntityReader}. * * @param data * @param classToRead * @param queryCustomConversions {@literal true} to call {@link CustomConversions#hasCustomReadTarget(Class, Class)}. * @return */ @SuppressWarnings("unchecked") private Object read(Map<String, Object> data, Class<?> classToRead, boolean queryCustomConversions) { if (queryCustomConversions) { customConversions.hasCustomReadTarget(Map.class, classToRead); } MyPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(classToRead); PreferredConstructor<?, MyPersistentProperty> constructor = persistentEntity.getPersistenceConstructor(); ParameterValueProvider<MyPersistentProperty> provider = constructor.isNoArgConstructor() // ? NONE // : new ParameterValueProvider<MyPersistentProperty>() { @Override public <T> T getParameterValue(Parameter<T, MyPersistentProperty> parameter) { return (T) getValue(data, parameter.getName(), parameter.getType().getType(), queryCustomConversions); } }; EntityInstantiator instantiator = instantiators.getInstantiatorFor(persistentEntity); Object instance = instantiator.createInstance(persistentEntity, provider); if (!persistentEntity.requiresPropertyPopulation()) { return instance; } PropertyValueProvider<MyPersistentProperty> valueProvider = new PropertyValueProvider<MyPersistentProperty>() { @Override public <T> T getPropertyValue(MyPersistentProperty property) { return (T) getValue(data, property.getName(), property.getType(), queryCustomConversions); } }; PersistentPropertyAccessor<?> accessor = new ConvertingPropertyAccessor<>( persistentEntity.getPropertyAccessor(instance), conversionService); readProperties(data, persistentEntity, valueProvider, accessor); return accessor.getBean(); }
Example #4
Source File: MappingCrateConverter.java From spring-data-crate with Apache License 2.0 | 4 votes |
@Override protected <T> T potentiallyConvertSpelValue(final Object object, final Parameter<T, CratePersistentProperty> parameter) { return readValue(object, parameter.getType(), parent); }