本文整理汇总了Java中org.springframework.data.mapping.model.ConvertingPropertyAccessor类的典型用法代码示例。如果您正苦于以下问题:Java ConvertingPropertyAccessor类的具体用法?Java ConvertingPropertyAccessor怎么用?Java ConvertingPropertyAccessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConvertingPropertyAccessor类属于org.springframework.data.mapping.model包,在下文中一共展示了ConvertingPropertyAccessor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeInternal
import org.springframework.data.mapping.model.ConvertingPropertyAccessor; //导入依赖的package包/类
public void writeInternal(final Object entity,
final Document targetDocument,
final DocumentDbPersistentEntity<?> entityInformation) {
if (entity == null) {
return;
}
if (entityInformation == null) {
throw new MappingException("no mapping metadata for entity type: " + entity.getClass().getName());
}
final ConvertingPropertyAccessor accessor = getPropertyAccessor(entity);
final DocumentDbPersistentProperty idProperty = entityInformation.getIdProperty();
if (idProperty != null) {
targetDocument.setId((String) accessor.getProperty(idProperty));
}
for (final Field field : entity.getClass().getDeclaredFields()) {
if (null != idProperty && field.getName().equals(idProperty.getName())) {
continue;
}
targetDocument.set(field.getName(),
accessor.getProperty(entityInformation.getPersistentProperty(field.getName())));
}
}
示例2: read
import org.springframework.data.mapping.model.ConvertingPropertyAccessor; //导入依赖的package包/类
private <S extends Object> S read(final SolrPersistentEntity<S> entity, final Map<String, ?> source, Object parent) {
ParameterValueProvider<SolrPersistentProperty> parameterValueProvider = getParameterValueProvider(entity, source,
parent);
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
final S instance = instantiator.createInstance(entity, parameterValueProvider);
final PersistentPropertyAccessor accessor = new ConvertingPropertyAccessor(entity.getPropertyAccessor(instance),
getConversionService());
entity.doWithProperties(new PropertyHandler<SolrPersistentProperty>() {
@Override
public void doWithPersistentProperty(SolrPersistentProperty persistentProperty) {
if (entity.isConstructorArgument(persistentProperty)) {
return;
}
Object o = getValue(persistentProperty, source, instance);
if (o != null) {
accessor.setProperty(persistentProperty, o);
}
}
});
return instance;
}
示例3: read
import org.springframework.data.mapping.model.ConvertingPropertyAccessor; //导入依赖的package包/类
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 (idProperty != null && documentAccessor.hasValue(idProperty)) {
idValue = readIdValue(idProperty, documentAccessor);
accessor.setProperty(idProperty, idValue);
}
VaultPropertyValueProvider valueProvider = new VaultPropertyValueProvider(
documentAccessor);
readProperties(entity, accessor, idProperty, documentAccessor, valueProvider);
return instance;
}
示例4: getPropertyAccessor
import org.springframework.data.mapping.model.ConvertingPropertyAccessor; //导入依赖的package包/类
private ConvertingPropertyAccessor getPropertyAccessor(Object entity) {
final DocumentDbPersistentEntity<?> entityInformation = mappingContext.getPersistentEntity(entity.getClass());
final PersistentPropertyAccessor accessor = entityInformation.getPropertyAccessor(entity);
return new ConvertingPropertyAccessor(accessor, conversionService);
}
示例5: write
import org.springframework.data.mapping.model.ConvertingPropertyAccessor; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
protected void write(Object source, final Map target, SolrPersistentEntity<?> entity) {
final PersistentPropertyAccessor accessor = new ConvertingPropertyAccessor(entity.getPropertyAccessor(source),
getConversionService());
entity.doWithProperties(new PropertyHandler<SolrPersistentProperty>() {
@SuppressWarnings("unchecked")
@Override
public void doWithPersistentProperty(SolrPersistentProperty persistentProperty) {
Object value = accessor.getProperty(persistentProperty);
if (value == null || persistentProperty.isReadonly()) {
return;
}
if (persistentProperty.containsWildcard() && !persistentProperty.isMap()) {
throw new IllegalArgumentException("Field '" + persistentProperty.getFieldName()
+ "' must not contain wildcards. Consider excluding Field from beeing indexed.");
}
Collection<SolrInputField> fields;
if (persistentProperty.isMap() && persistentProperty.containsWildcard()) {
fields = writeWildcardMapPropertyToTarget(target, persistentProperty, (Map<?, ?>) value);
} else {
fields = writeRegularPropertyToTarget(target, persistentProperty, value);
}
if (persistentProperty.isBoosted()) {
for (SolrInputField field : fields) {
field.setBoost(persistentProperty.getBoost());
}
}
}
});
if (entity.isBoosted() && target instanceof SolrInputDocument) {
((SolrInputDocument) target).setDocumentBoost(entity.getBoost());
}
}