org.springframework.data.mapping.model.SimpleTypeHolder Java Examples

The following examples show how to use org.springframework.data.mapping.model.SimpleTypeHolder. 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: MybatisPersistentPropertyImpl.java    From spring-data-mybatis with Apache License 2.0 7 votes vote down vote up
/**
 * Creates a new {@link AnnotationBasedPersistentProperty}.
 * @param property must not be {@literal null}.
 * @param owner must not be {@literal null}.
 */
public MybatisPersistentPropertyImpl(Property property,
		PersistentEntity<?, MybatisPersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder) {

	super(property, owner, simpleTypeHolder);

	this.isAssociation = Lazy.of(() -> ASSOCIATION_ANNOTATIONS.stream()
			.anyMatch(this::isAnnotationPresent));
	this.usePropertyAccess = detectPropertyAccess();
	this.associationTargetType = detectAssociationTargetType();
	this.updateable = detectUpdatability();

	this.isIdProperty = Lazy.of(
			() -> ID_ANNOTATIONS.stream().anyMatch(it -> isAnnotationPresent(it)));
	this.isEntity = Lazy.of(getActualType().isAnnotationPresent(Entity.class));
}
 
Example #2
Source File: DefaultNeo4jPersistentProperty.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link AnnotationBasedPersistentProperty}.
 *
 * @param property         must not be {@literal null}.
 * @param owner            must not be {@literal null}.
 * @param simpleTypeHolder type holder
 */
DefaultNeo4jPersistentProperty(Property property,
	PersistentEntity<?, Neo4jPersistentProperty> owner,
	Neo4jMappingContext mappingContext,
	SimpleTypeHolder simpleTypeHolder) {

	super(property, owner, simpleTypeHolder);

	this.graphPropertyName = Lazy.of(this::computeGraphPropertyName);
	this.isAssociation = Lazy.of(() -> {

		Class<?> targetType = getActualType();
		return !(simpleTypeHolder.isSimpleType(targetType) || mappingContext.hasCustomWriteTarget(targetType));
	});
	this.mappingContext = mappingContext;
}
 
Example #3
Source File: SimpleCratePersistentProperty.java    From spring-data-crate with Apache License 2.0 6 votes vote down vote up
public SimpleCratePersistentProperty(Field field, PropertyDescriptor propertyDescriptor, 
									 PersistentEntity<?, CratePersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
	super(field, propertyDescriptor, owner, simpleTypeHolder);
	
	this.fieldNamingStrategy = INSTANCE;

	String fieldName = getFieldName();
	
	if(RESERVED_ID_FIELD_NAME.equals(fieldName)) {				
		throw new MappingException(format(RESERVED_ID, fieldName, owner.getType()));
	}
	
	if(RESERVED_VESRION_FIELD_NAME.equals(fieldName)) {				
		throw new MappingException(format(RESERVED_VERSION, fieldName, owner.getType()));
	}
	
	if(startsWithIgnoreCase(fieldName, "_")) {
		throw new MappingException(format(STARTS_WITH_UNDERSCORE, fieldName, owner.getType()));
	}
}
 
Example #4
Source File: CustomConversions.java    From spring-data-crate with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new instance with a given list of converters.
 * @param converters the list of custom converters.
 */
public CustomConversions(final List<?> converters) {
  notNull(converters);

  readingPairs = new LinkedHashSet<>();
  writingPairs = new LinkedHashSet<>();
  customSimpleTypes = new HashSet<>();
  customReadTargetTypes = new ConcurrentHashMap<>();

  this.converters = new ArrayList<>();
  this.converters.addAll(converters);
  this.converters.add(LocaleToStringConverter.INSTANCE);
  this.converters.add(DateToLongConverter.INSTANCE);
  this.converters.add(LongToDateConverter.INSTANCE);
  
  for (Object converter : this.converters) {
    registerConversion(converter);
  }

  simpleTypeHolder = new SimpleTypeHolder(customSimpleTypes, HOLDER);
}
 
Example #5
Source File: Target_AbstractMappingContext.java    From spring-graalvm-native with Apache License 2.0 6 votes vote down vote up
@Substitute
protected Target_AbstractMappingContext()  {
	this.persistentPropertyPathFactory = new PersistentPropertyPathFactory<E, P>((AbstractMappingContext)(Object)this);

	EntityInstantiators instantiators = new EntityInstantiators();
	Target_BeanWrapperPropertyAccessorFactory accessorFactory = Target_BeanWrapperPropertyAccessorFactory.INSTANCE;

	this.persistentPropertyAccessorFactory = new InstantiationAwarePropertyAccessorFactory(accessorFactory,
			instantiators);

	NONE = Optional.empty();
	persistentEntities = new HashMap<>();
	evaluationContextProvider = EvaluationContextProvider.DEFAULT;
	initialEntitySet = new HashSet<>();
	strict = false;
	simpleTypeHolder = SimpleTypeHolder.DEFAULT;
	lock = new ReentrantReadWriteLock();
	read = lock.readLock();
	write = lock.writeLock();
}
 
Example #6
Source File: ArangoMappingContext.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
protected ArangoPersistentProperty createPersistentProperty(
	final Property property,
	final DefaultArangoPersistentEntity<?> owner,
	final SimpleTypeHolder simpleTypeHolder) {
	return new DefaultArangoPersistentProperty(property, owner, simpleTypeHolder, fieldNamingStrategy);
}
 
Example #7
Source File: CustomConversions.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * Create new instance registering given converters
 *
 * @param converters
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public CustomConversions(List converters) {
	this.converters = (converters != null ? new ArrayList<Object>(converters) : new ArrayList<Object>());
	this.readingPairs = new HashSet<ConvertiblePair>();
	this.writingPairs = new HashSet<ConvertiblePair>();
	this.customSimpleTypes = new HashSet<Class<?>>();

	this.simpleTypeHolder = new SimpleTypeHolder(customSimpleTypes, SolrSimpleTypes.HOLDER);

	this.converters.add(GeoConverters.StringToPointConverter.INSTANCE);
	this.converters.add(GeoConverters.Point3DToStringConverter.INSTANCE);
	this.converters.add(new SolrjConverters.UpdateToSolrInputDocumentConverter());

	// Register Joda-Time converters only if Joda-Time was found in the
	// classpath.
	if (VersionUtil.isJodaTimeAvailable()) {
		this.converters.add(DateTimeConverters.DateToJodaDateTimeConverter.INSTANCE);
		this.converters.add(DateTimeConverters.JodaDateTimeToDateConverter.INSTANCE);
		this.converters.add(DateTimeConverters.DateToLocalDateTimeConverter.INSTANCE);
		this.converters.add(DateTimeConverters.JodaLocalDateTimeToDateConverter.INSTANCE);
	}

	for (Object converter : this.converters) {
		registerConversion(converter);
	}
}
 
Example #8
Source File: DefaultArangoPersistentProperty.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public DefaultArangoPersistentProperty(final Property property,
	final PersistentEntity<?, ArangoPersistentProperty> owner, final SimpleTypeHolder simpleTypeHolder,
	final FieldNamingStrategy fieldNamingStrategy) {
	super(property, owner, simpleTypeHolder);
	this.fieldNamingStrategy = fieldNamingStrategy != null ? fieldNamingStrategy
			: PropertyNameFieldNamingStrategy.INSTANCE;
}
 
Example #9
Source File: DatastorePersistentPropertyImpl.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param property the property to store
 * @param owner the entity to which this property belongs
 * @param simpleTypeHolder the type holder
 * @param fieldNamingStrategy the naming strategy used to get the column name of this
 * property
 */
DatastorePersistentPropertyImpl(Property property,
		PersistentEntity<?, DatastorePersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder, FieldNamingStrategy fieldNamingStrategy) {
	super(property, owner, simpleTypeHolder);
	this.fieldNamingStrategy = (fieldNamingStrategy != null)
			? fieldNamingStrategy
			: PropertyNameFieldNamingStrategy.INSTANCE;
	verify();
}
 
Example #10
Source File: Neo4jMappingContext.java    From sdn-rx with Apache License 2.0 4 votes vote down vote up
@Override
protected Neo4jPersistentProperty createPersistentProperty(Property property,
	Neo4jPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {

	return new DefaultNeo4jPersistentProperty(property, owner, this, simpleTypeHolder);
}
 
Example #11
Source File: KeyValueMappingContext.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected P createPersistentProperty(Property property, E owner, SimpleTypeHolder simpleTypeHolder) {
	return (P) new KeyValuePersistentProperty<>(property, owner, simpleTypeHolder);
}
 
Example #12
Source File: KeyValuePersistentProperty.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
public KeyValuePersistentProperty(Property property, PersistentEntity<?, P> owner,
		SimpleTypeHolder simpleTypeHolder) {
	super(property, owner, simpleTypeHolder);
}
 
Example #13
Source File: CrateMappingContext.java    From spring-data-crate with Apache License 2.0 4 votes vote down vote up
@Override
protected CratePersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor,
																   SimpleCratePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new SimpleCratePersistentProperty(field, descriptor, owner, simpleTypeHolder);
}
 
Example #14
Source File: TypicalEntityReaderBenchmark.java    From spring-data-dev-tools with Apache License 2.0 4 votes vote down vote up
MyPersistentProperty(Property property, PersistentEntity<?, MyPersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder) {
	super(property, owner, simpleTypeHolder);
}
 
Example #15
Source File: TypicalEntityReaderBenchmark.java    From spring-data-dev-tools with Apache License 2.0 4 votes vote down vote up
@Override
protected MyPersistentProperty createPersistentProperty(Property property, MyPersistentEntity<?> owner,
		SimpleTypeHolder simpleTypeHolder) {
	return new MyPersistentProperty(property, owner, simpleTypeHolder);
}
 
Example #16
Source File: MybatisMapperBuildAssistant.java    From spring-data-mybatis with Apache License 2.0 4 votes vote down vote up
protected MybatisPersistentProperty createPersistentProperty(Property property,
		MybatisPersistentEntityImpl<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new MybatisPersistentPropertyImpl(property, owner, simpleTypeHolder);
}
 
Example #17
Source File: DynamoDBMappingContext.java    From spring-data-dynamodb with Apache License 2.0 4 votes vote down vote up
@Override
protected DynamoDBPersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor,
		DynamoDBPersistentEntityImpl<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new DynamoDBPersistentPropertyImpl(field, descriptor, owner, simpleTypeHolder);

}
 
Example #18
Source File: MybatisMappingContext.java    From spring-data-mybatis with Apache License 2.0 4 votes vote down vote up
@Override
protected MybatisPersistentProperty createPersistentProperty(Property property,
		MybatisPersistentEntityImpl<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new MybatisPersistentPropertyImpl(property, owner, simpleTypeHolder);
}
 
Example #19
Source File: VaultMappingContext.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
@Override
protected VaultPersistentProperty createPersistentProperty(Property property, VaultPersistentEntity<?> owner,
		SimpleTypeHolder simpleTypeHolder) {
	return new VaultPersistentProperty(property, owner, simpleTypeHolder);
}
 
Example #20
Source File: FirestoreMappingContext.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
@Override
protected FirestorePersistentProperty createPersistentProperty(Property property,
		FirestorePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new FirestorePersistentPropertyImpl(property, owner, simpleTypeHolder);
}
 
Example #21
Source File: SpannerMappingContext.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
@Override
protected SpannerPersistentProperty createPersistentProperty(Property property,
		SpannerPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new SpannerPersistentPropertyImpl(property, owner, simpleTypeHolder,
			this.fieldNamingStrategy);
}
 
Example #22
Source File: DatastoreMappingContext.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
@Override
protected DatastorePersistentProperty createPersistentProperty(Property property,
		DatastorePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new DatastorePersistentPropertyImpl(property, owner, simpleTypeHolder,
			this.fieldNamingStrategy);
}
 
Example #23
Source File: BasicCosmosPersistentProperty.java    From spring-data-cosmosdb with MIT License 4 votes vote down vote up
public BasicCosmosPersistentProperty(Property property, CosmosPersistentEntity<?> owner,
                                     SimpleTypeHolder simpleTypeHolder) {
    super(property, owner, simpleTypeHolder);
}
 
Example #24
Source File: CosmosMappingContext.java    From spring-data-cosmosdb with MIT License 4 votes vote down vote up
@Override
public CosmosPersistentProperty createPersistentProperty(Property property,
                                                         BasicCosmosPersistentEntity<?> owner,
                                                         SimpleTypeHolder simpleTypeHolder) {
    return new BasicCosmosPersistentProperty(property, owner, simpleTypeHolder);
}
 
Example #25
Source File: SimpleSolrMappingContext.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Override
protected SolrPersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor,
		SimpleSolrPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
	return new SimpleSolrPersistentProperty(field, descriptor, owner, simpleTypeHolder);
}
 
Example #26
Source File: SimpleSolrPersistentProperty.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public SimpleSolrPersistentProperty(Field field, PropertyDescriptor propertyDescriptor,
		PersistentEntity<?, SolrPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
	super(field, propertyDescriptor, owner, simpleTypeHolder);
}
 
Example #27
Source File: SpannerPersistentPropertyImpl.java    From spring-cloud-gcp with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new {@link SpannerPersistentPropertyImpl}.
 *
 * @param property the property to store
 * @param owner the entity to which this property belongs
 * @param simpleTypeHolder the type holder
 * @param fieldNamingStrategy the naming strategy used to get the column name of this
 * property
 */
SpannerPersistentPropertyImpl(Property property,
		PersistentEntity<?, SpannerPersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder, FieldNamingStrategy fieldNamingStrategy) {
	super(property, owner, simpleTypeHolder);
	this.fieldNamingStrategy = (fieldNamingStrategy != null)
			? fieldNamingStrategy
			: PropertyNameFieldNamingStrategy.INSTANCE;
}
 
Example #28
Source File: VaultPersistentProperty.java    From spring-vault with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link VaultPersistentProperty}.
 * @param property must not be {@literal null}.
 * @param owner must not be {@literal null}.
 * @param simpleTypeHolder must not be {@literal null}.
 */
public VaultPersistentProperty(Property property, PersistentEntity<?, VaultPersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder) {

	super(property, owner, simpleTypeHolder);
}
 
Example #29
Source File: FirestorePersistentPropertyImpl.java    From spring-cloud-gcp with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor.
 *
 * @param property the property to store
 * @param owner the entity to which this property belongs
 * @param simpleTypeHolder the type holder
 */
FirestorePersistentPropertyImpl(Property property,
		PersistentEntity<?, FirestorePersistentProperty> owner,
		SimpleTypeHolder simpleTypeHolder) {
	super(property, owner, simpleTypeHolder);
}
 
Example #30
Source File: CustomConversions.java    From spring-data-crate with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the simple type holder.
 *
 * @return the simple type holder.
 */
public SimpleTypeHolder getSimpleTypeHolder() {
  return simpleTypeHolder;
}