Java Code Examples for

The following examples show how to use These examples are extracted from open source projects. 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
private void readProperties(Map<String, Object> data, MyPersistentEntity<?> persistentEntity,
		PropertyValueProvider<MyPersistentProperty> valueProvider, PersistentPropertyAccessor<?> accessor) {

	for (MyPersistentProperty prop : persistentEntity) {

		if (prop.isAssociation() && !persistentEntity.isConstructorArgument(prop)) {

		// We skip the id property since it was already set

		if (persistentEntity.isIdProperty(prop)) {

		if (persistentEntity.isConstructorArgument(prop) || !data.containsKey(persistentEntity.getName())) {

		accessor.setProperty(prop, valueProvider.getPropertyValue(prop));
Example 2
Source Project: spring-data   Source File:    License: Apache License 2.0 5 votes vote down vote up
private ParameterValueProvider<ArangoPersistentProperty> getParameterProvider(
	final ArangoPersistentEntity<?> entity,
	final VPackSlice source) {

	final PropertyValueProvider<ArangoPersistentProperty> provider = new ArangoPropertyValueProvider(entity,
	return new PersistentEntityParameterValueProvider<>(entity, provider, null);
Example 3
 * Typical code used to read entities in {@link}.
 * @param data
 * @param classToRead
 * @param queryCustomConversions {@literal true} to call {@link CustomConversions#hasCustomReadTarget(Class, Class)}.
 * @return
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>() {

				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>() {

		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();