org.springframework.data.util.Lazy Java Examples

The following examples show how to use org.springframework.data.util.Lazy. 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: IdDescription.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
private IdDescription(
	@Nullable Class<? extends IdGenerator<?>> idGeneratorClass,
	@Nullable String idGeneratorRef,
	@Nullable String graphPropertyName
) {
	this.idGeneratorClass = idGeneratorClass;
	this.idGeneratorRef = idGeneratorRef != null && idGeneratorRef.isEmpty() ? null : idGeneratorRef;
	this.graphPropertyName = graphPropertyName;
	this.idExpression = Lazy.of(() -> {
		final Node rootNode = anyNode(NAME_OF_ROOT_NODE);
		if (this.isInternallyGeneratedId()) {
			return Functions.id(rootNode);
		} else {
			return this.getOptionalGraphPropertyName()
				.map(propertyName -> property(NAME_OF_ROOT_NODE, propertyName)).get();
		}
	});
}
 
Example #4
Source File: MappingAuditableBeanWrapperFactory.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link MappingAuditingMetadata} instance from the given
 * {@link PersistentEntity}.
 */
public <P> MappingAuditingMetadata(
		MappingContext<?, ? extends PersistentProperty<?>> context,
		Class<?> type) {

	Assert.notNull(type, "Type must not be null!");

	this.createdByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedBy.class,
					org.springframework.data.mybatis.annotation.CreatedBy.class));
	this.createdDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedDate.class,
					org.springframework.data.mybatis.annotation.CreatedDate.class));
	this.lastModifiedByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedBy.class,
					org.springframework.data.mybatis.annotation.LastModifiedBy.class));
	this.lastModifiedDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedDate.class,
					org.springframework.data.mybatis.annotation.LastModifiedDate.class));

	this.isAuditable = Lazy.of( //
			() -> Arrays
					.asList(createdByPaths, createdDatePaths, lastModifiedByPaths,
							lastModifiedDatePaths) //
					.stream() //
					.anyMatch(it -> !it.isEmpty())//
	);
}
 
Example #5
Source File: DefaultNeo4jPersistentEntity.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
DefaultNeo4jPersistentEntity(TypeInformation<T> information) {
	super(information);

	this.isExplicitEntity = this.isAnnotationPresent(Node.class);
	this.primaryLabel = computePrimaryLabel();
	this.additionalLabels = Lazy.of(this::computeAdditionalLabels);
	this.graphProperties = Lazy.of(this::computeGraphProperties);
	this.dynamicLabelsProperty = Lazy
		.of(() -> getGraphProperties().stream().map(Neo4jPersistentProperty.class::cast)
			.filter(Neo4jPersistentProperty::isDynamicLabels).findFirst().orElse(null));
}
 
Example #6
Source File: StoreFragmentDetector.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public StoreFragmentDetector(Environment environment, ResourceLoader loader, String postfix, String[] basePackages, MetadataReaderFactory metadataReaderFactory) {
	this.environment = environment;
	this.resourceLoader = loader;
	this.postfix = postfix;

	this.basePackages = new HashSet<String>(Arrays.asList(basePackages));
	this.basePackages.add("org.springframework.content.fragments");
	this.basePackages.add("internal.org.springframework.content.fragments");

	this.metadataReaderFactory = metadataReaderFactory;
	this.implementationCandidates = Lazy.of(() -> findCandidateBeanDefinitions());
}