Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-simons committed Apr 21, 2020
1 parent 4fdda0b commit f8f8200
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions core/src/main/java/org/neo4j/ogm/autoindex/AutoIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -348,24 +349,16 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}

AutoIndex autoIndex = (AutoIndex) o;

// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(properties, autoIndex.properties)) {
return false;
}
if (!owningType.equals(autoIndex.owningType)) {
return false;
}
return type == autoIndex.type;
return Arrays.equals(properties, autoIndex.properties) &&
owningType.equals(autoIndex.owningType) &&
type == autoIndex.type;
}

@Override
public int hashCode() {
int result = Arrays.hashCode(properties);
result = 31 * result + owningType.hashCode();
result = 31 * result + type.hashCode();
int result = Objects.hash(owningType, type);
result = 31 * result + Arrays.hashCode(properties);
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/neo4j/ogm/metadata/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ Class<?> getTypeParameterDescriptorForRelationship(String relationshipType, Dire
* @return If this class contains any fields/properties annotated with @Index.
*/
public boolean containsIndexes() {
return !getIndexFields().isEmpty() || !getCompositeIndexes().isEmpty();
return !(getIndexFields().isEmpty() && getCompositeIndexes().isEmpty());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void shouldPreferMethodBasedAccessToFieldAccessWhenReadingFromObjectsWith
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());

DummyDomainObject domainObject = new DummyDomainObject();
domainObject.nonAnnotatedTestProperty = new Double(30.16);
domainObject.nonAnnotatedTestProperty = 30.16;

FieldInfo objectAccess = classInfo.getFieldInfo("nonAnnotatedTestProperty");
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
Expand Down

0 comments on commit f8f8200

Please sign in to comment.