Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

chore: consider genericArgs contents in TypeHint equals and hashCode #83

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package ai.timefold.jpyinterpreter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import ai.timefold.jpyinterpreter.types.PythonLikeType;

Expand Down Expand Up @@ -31,4 +33,33 @@ public static TypeHint withoutAnnotations(PythonLikeType type) {
return new TypeHint(type, Collections.emptyList());
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TypeHint typeHint)) {
return false;
}
return Objects.equals(type, typeHint.type) && Objects.deepEquals(genericArgs,
typeHint.genericArgs)
&& Objects.equals(javaGetterType,
typeHint.javaGetterType)
&& Objects.equals(annotationList, typeHint.annotationList);
}

@Override
public int hashCode() {
return Objects.hash(type, annotationList, Arrays.hashCode(genericArgs), javaGetterType);
}

@Override
public String toString() {
return "TypeHint{" +
"type=" + type +
", annotationList=" + annotationList +
", genericArgs=" + Arrays.toString(genericArgs) +
", javaGetterType=" + javaGetterType +
'}';
}
}
Loading