|
16 | 16 |
|
17 | 17 | import com.google.api.generator.engine.ast.TypeNode; |
18 | 18 | import com.google.auto.value.AutoValue; |
| 19 | +import java.util.Objects; |
19 | 20 | import javax.annotation.Nullable; |
20 | 21 |
|
21 | 22 | @AutoValue |
@@ -48,6 +49,37 @@ public boolean hasResourceReference() { |
48 | 49 | return type().equals(TypeNode.STRING) && resourceReference() != null; |
49 | 50 | } |
50 | 51 |
|
| 52 | + @Override |
| 53 | + public boolean equals(Object o) { |
| 54 | + if (!(o instanceof Field)) { |
| 55 | + return false; |
| 56 | + } |
| 57 | + |
| 58 | + Field other = (Field) o; |
| 59 | + return name().equals(other.name()) |
| 60 | + && type().equals(other.type()) |
| 61 | + && isMessage() == other.isMessage() |
| 62 | + && isEnum() == other.isEnum() |
| 63 | + && isRepeated() == other.isRepeated() |
| 64 | + && isMap() == other.isMap() |
| 65 | + && isContainedInOneof() == other.isContainedInOneof() |
| 66 | + && Objects.equals(resourceReference(), other.resourceReference()) |
| 67 | + && Objects.equals(description(), other.description()); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public int hashCode() { |
| 72 | + return 17 * name().hashCode() |
| 73 | + + 19 * type().hashCode() |
| 74 | + + (isMessage() ? 1 : 0) * 23 |
| 75 | + + (isEnum() ? 1 : 0) * 29 |
| 76 | + + (isRepeated() ? 1 : 0) * 31 |
| 77 | + + (isMap() ? 1 : 0) * 37 |
| 78 | + + (isContainedInOneof() ? 1 : 0) * 41 |
| 79 | + + (resourceReference() == null ? 0 : resourceReference().hashCode()) |
| 80 | + + (description() == null ? 0 : description().hashCode()); |
| 81 | + } |
| 82 | + |
51 | 83 | public abstract Builder toBuilder(); |
52 | 84 |
|
53 | 85 | public static Builder builder() { |
|
0 commit comments