use of org.neo4j.ogm.id.InternalIdStrategy in project neo4j-ogm by neo4j.
the class ClassInfo method getOrComputeIdentityField.
private Optional<FieldInfo> getOrComputeIdentityField() {
Optional<FieldInfo> result = this.identityField;
if (result == null) {
synchronized (this) {
result = this.identityField;
if (result == null) {
// Didn't want to add yet another method related to determining the identy field
// so the actual resolving of the field inside the Double-checked locking here
// has been inlined.
Collection<FieldInfo> identityFields = getFieldInfos(FieldInfo::isInternalIdentity);
if (identityFields.size() == 1) {
this.identityField = Optional.of(identityFields.iterator().next());
} else if (identityFields.size() > 1) {
throw new MetadataException("Expected exactly one internal identity field (@Id with " + "InternalIdStrategy), found " + identityFields.size() + " " + identityFields);
} else {
this.identityField = fieldsInfo.fields().stream().filter(f -> "id".equals(f.getName())).filter(f -> "java.lang.Long".equals(f.getTypeDescriptor())).findFirst();
}
result = this.identityField;
}
}
}
return result;
}
Aggregations