Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
private <S extends Object> S read(final MongoPersistentEntity<S> entity, final Document bson, final ObjectPath path) { SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext); DocumentAccessor documentAccessor = new DocumentAccessor(bson); PreferredConstructor<S, MongoPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor(); ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null && persistenceConstructor.hasParameters() ? getParameterProvider(entity, documentAccessor, evaluator, path) : NoOpParameterValueProvider.INSTANCE; EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity); S instance = instantiator.createInstance(entity, provider); if (entity.requiresPropertyPopulation()) { return populateProperties(entity, documentAccessor, path, evaluator, instance); } return instance; }
Object instance = instantiator.createInstance((RedisPersistentEntity<RedisPersistentProperty>) entity, new PersistentEntityParameterValueProvider<>(entity, new ConverterAwareParameterValueProvider(path, source, conversionService), this.conversionService));
@SuppressWarnings({ "unchecked" }) @Override public <T> T createInstance(Class<T> clazz, Map<String, Object> propertyValues) { Neo4jPersistentEntity<T> persistentEntity = (Neo4jPersistentEntity<T>) context.getRequiredPersistentEntity(clazz); EntityInstantiator sdnInstantiator = context.getInstantiatorFor(persistentEntity); return sdnInstantiator.createInstance(persistentEntity, getParameterProvider(propertyValues, conversionService)); }
Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
private <S extends Object> S read(final MongoPersistentEntity<S> entity, final Document bson, final ObjectPath path) { SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext); DocumentAccessor documentAccessor = new DocumentAccessor(bson); PreferredConstructor<S, MongoPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor(); ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null && persistenceConstructor.hasParameters() ? getParameterProvider(entity, documentAccessor, evaluator, path) : NoOpParameterValueProvider.INSTANCE; EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity); S instance = instantiator.createInstance(entity, provider); if (entity.requiresPropertyPopulation()) { return populateProperties(entity, documentAccessor, path, evaluator, instance); } return instance; }
@Override public <T, E extends PersistentEntity<? extends T, P>, P extends PersistentProperty<P>> T createInstance(E entity, ParameterValueProvider<P> provider) { EntityInstantiator instantiator = this.entityInstantiators.get(entity.getTypeInformation()); if (instantiator == null) { instantiator = potentiallyCreateAndRegisterEntityInstantiator(entity); } return instantiator.createInstance(entity, provider); }
@Override public <T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) { return entityInstantiators.getInstantiatorFor(entity) // .createInstance(entity, new ConvertingParameterValueProvider<>(parameterValueProvider)); }
private Object instantiatePrimaryKey(CassandraPersistentEntity<?> entity, CassandraPersistentProperty keyProperty, CassandraValueProvider propertyProvider) { return this.instantiators.getInstantiatorFor(entity).createInstance(entity, newParameterValueProvider(entity, propertyProvider)); }
@Override public <T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) { return entityInstantiators.getInstantiatorFor(entity) // .createInstance(entity, new ConvertingParameterValueProvider<>(parameterValueProvider)); }
@Override public <T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) { return entityInstantiators.getInstantiatorFor(entity) // .createInstance(entity, new ConvertingParameterValueProvider<>(parameterValueProvider)); }
@SuppressWarnings({ "unchecked" }) @Override public <T> T createInstance(Class<T> clazz, Map<String, Object> propertyValues) { Neo4jPersistentEntity<T> persistentEntity = (Neo4jPersistentEntity<T>) context.getRequiredPersistentEntity(clazz); EntityInstantiator sdnInstantiator = context.getInstantiatorFor(persistentEntity); return sdnInstantiator.createInstance(persistentEntity, getParameterProvider(propertyValues, conversionService)); }
private ConvertingPropertyAccessor getConvertingPropertyAccessor(AerospikePersistentEntity<?> entity, RecordReadingPropertyValueProvider recordReadingPropertyValueProvider) { EntityInstantiator instantiator = entityInstantiators.getInstantiatorFor(entity); Object instance = instantiator.createInstance(entity, new PersistentEntityParameterValueProvider<>(entity, recordReadingPropertyValueProvider, null)); return new ConvertingPropertyAccessor(entity.getPropertyAccessor(instance), conversionService); }
private <S, V> S doRead(CassandraPersistentEntity<S> entity, V value, Function<SpELExpressionEvaluator, CassandraValueProvider> valueProviderSupplier) { SpELExpressionEvaluator expressionEvaluator = new DefaultSpELExpressionEvaluator(value, this.spELContext); CassandraValueProvider valueProvider = valueProviderSupplier.apply(expressionEvaluator); PersistentEntityParameterValueProvider<CassandraPersistentProperty> parameterValueProvider = newParameterValueProvider( entity, valueProvider); EntityInstantiator instantiator = this.instantiators.getInstantiatorFor(entity); S instance = instantiator.createInstance(entity, parameterValueProvider); ConvertingPropertyAccessor propertyAccessor = newConvertingPropertyAccessor(instance, entity); readProperties(entity, valueProvider, propertyAccessor); return (S) propertyAccessor.getBean(); }
Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
private <S> S read(VaultPersistentEntity<S> entity, SecretDocument source) { ParameterValueProvider<VaultPersistentProperty> provider = getParameterProvider( entity, source); EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity); S instance = instantiator.createInstance(entity, provider); PersistentPropertyAccessor accessor = new ConvertingPropertyAccessor( entity.getPropertyAccessor(instance), conversionService); VaultPersistentProperty idProperty = entity.getIdProperty(); SecretDocumentAccessor documentAccessor = new SecretDocumentAccessor(source); // make sure id property is set before all other properties Object idValue; if (entity.requiresPropertyPopulation()) { if (idProperty != null && !entity.isConstructorArgument(idProperty) && documentAccessor.hasValue(idProperty)) { idValue = readIdValue(idProperty, documentAccessor); accessor.setProperty(idProperty, idValue); } VaultPropertyValueProvider valueProvider = new VaultPropertyValueProvider( documentAccessor); readProperties(entity, accessor, idProperty, documentAccessor, valueProvider); } return instance; }
private Object readEntity( final TypeInformation<?> type, final VPackSlice source, final ArangoPersistentEntity<?> entity) { if (!source.isObject()) { throw new MappingException( String.format("Can't read entity type %s from VPack type %s!", type, source.getType())); } final EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity); final ParameterValueProvider<ArangoPersistentProperty> provider = getParameterProvider(entity, source); final Object instance = instantiator.createInstance(entity, provider); final PersistentPropertyAccessor<?> accessor = entity.getPropertyAccessor(instance); final String id = source.get(_ID).isString() ? source.get(_ID).getAsString() : null; entity.doWithProperties((final ArangoPersistentProperty property) -> { if (!entity.isConstructorArgument(property)) { final VPackSlice value = source.get(property.getFieldName()); readProperty(entity, id, accessor, value, property); } }); entity.doWithAssociations((final Association<ArangoPersistentProperty> association) -> { final ArangoPersistentProperty property = association.getInverse(); if (!entity.isConstructorArgument(property)) { final VPackSlice value = source.get(property.getFieldName()); readProperty(entity, id, accessor, value, property); } }); return instance; }
private Object readEntity( final TypeInformation<?> type, final VPackSlice source, final ArangoPersistentEntity<?> entity) { if (!source.isObject()) { throw new MappingException( String.format("Can't read entity type %s from VPack type %s!", type, source.getType())); } final EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity); final ParameterValueProvider<ArangoPersistentProperty> provider = getParameterProvider(entity, source); final Object instance = instantiator.createInstance(entity, provider); final PersistentPropertyAccessor<?> accessor = entity.getPropertyAccessor(instance); final String id = source.get(_ID).isString() ? source.get(_ID).getAsString() : null; entity.doWithProperties((final ArangoPersistentProperty property) -> { if (!entity.isConstructorArgument(property)) { final VPackSlice value = source.get(property.getFieldName()); readProperty(entity, id, accessor, value, property); } }); entity.doWithAssociations((final Association<ArangoPersistentProperty> association) -> { final ArangoPersistentProperty property = association.getInverse(); if (!entity.isConstructorArgument(property)) { final VPackSlice value = source.get(property.getFieldName()); readProperty(entity, id, accessor, value, property); } }); return instance; }