DATACMNS-867 - Lazify lookups in AbstractPersistentProperty.
This commit is contained in:
@@ -50,10 +50,10 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
CAUSE_FIELD = ReflectionUtils.findField(Throwable.class, "cause");
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final TypeInformation<?> information;
|
||||
protected final Class<?> rawType;
|
||||
protected final Optional<Association<P>> association;
|
||||
private final String name;
|
||||
private final TypeInformation<?> information;
|
||||
private final Class<?> rawType;
|
||||
private final Lazy<Optional<Association<P>>> association;
|
||||
private final @Getter PersistentEntity<?, P> owner;
|
||||
private final @Getter(AccessLevel.PROTECTED) Property property;
|
||||
private final Lazy<Integer> hashCode;
|
||||
@@ -71,7 +71,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
this.information = PropertyPath.from(Pattern.quote(property.getName()), owner.getTypeInformation())
|
||||
.getTypeInformation();
|
||||
this.property = property;
|
||||
this.association = isAssociation() ? Optional.of(createAssociation()) : Optional.empty();
|
||||
this.association = Lazy.of(() -> isAssociation() ? Optional.of(createAssociation()) : Optional.empty());
|
||||
this.owner = owner;
|
||||
|
||||
this.hashCode = Lazy.of(property::hashCode);
|
||||
@@ -206,7 +206,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
*/
|
||||
@Override
|
||||
public Optional<Association<P>> getAssociation() {
|
||||
return association;
|
||||
return association.get();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -56,8 +56,11 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
|
||||
private final Optional<Value> value;
|
||||
private final Map<Class<? extends Annotation>, Optional<? extends Annotation>> annotationCache = new HashMap<>();
|
||||
|
||||
private Lazy<Boolean> isTransient;
|
||||
private Lazy<Boolean> usePropertyAccess;
|
||||
private final Lazy<Boolean> usePropertyAccess = Lazy.of(() -> findPropertyOrOwnerAnnotation(AccessType.class)//
|
||||
.map(it -> Type.PROPERTY.equals(it.value()))//
|
||||
.orElse(super.usePropertyAccess()));
|
||||
private final Lazy<Boolean> isTransient = Lazy.of(() -> super.isTransient() || isAnnotationPresent(Transient.class)
|
||||
|| isAnnotationPresent(Value.class) || isAnnotationPresent(Autowired.class));
|
||||
|
||||
/**
|
||||
* Creates a new {@link AnnotationBasedPersistentProperty}.
|
||||
@@ -73,11 +76,6 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
|
||||
populateAnnotationCache(property);
|
||||
|
||||
this.value = findAnnotation(Value.class);
|
||||
this.usePropertyAccess = Lazy.of(() -> findPropertyOrOwnerAnnotation(AccessType.class)//
|
||||
.map(it -> Type.PROPERTY.equals(it.value()))//
|
||||
.orElse(super.usePropertyAccess()));
|
||||
this.isTransient = Lazy.of(() -> super.isTransient() || isAnnotationPresent(Transient.class)
|
||||
|| isAnnotationPresent(Value.class) || isAnnotationPresent(Autowired.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user