@Test public void testEquals() { Dummy base = new Dummy(Value.values()); Dummy same = new Dummy(Value.values()); Dummy size = new Dummy(Operator.values()); Dummy diff = new Dummy(Arrays.copyOfRange( Operator.values(), 0, Value.values().length)); assertThat(base, is(base)); assertThat(base, is(same)); assertThat(base, not(size)); assertThat(base, not(diff)); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o.getClass().equals(getClass()))) { return false; } PEnumDescriptor<?> other = (PEnumDescriptor<?>) o; if (!getQualifiedName().equals(other.getQualifiedName()) || getValues().length != other.getValues().length) { return false; } for (PEnumValue<?> value : getValues()) { PEnumValue<?> ovI = other.findById(value.asInteger()); if (ovI != null && !value.asString().equals(ovI.asString())) { return false; } } return true; }
PEnumDescriptor extends PDeclaredDescriptor<T> { @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o.getClass().equals(getClass()))) { return false; } PEnumDescriptor<?> other = (PEnumDescriptor<?>) o; if (!getQualifiedName().equals(other.getQualifiedName()) || getValues().length != other.getValues().length) { return false; } for (PEnumValue<?> value : getValues()) { PEnumValue<?> ovI = other.findById(value.asInteger()); if (ovI != null && !value.asString().equals(ovI.asString())) { return false; } } return true; } }
PEnumDescriptor extends PDeclaredDescriptor<T> { @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o.getClass().equals(getClass()))) { return false; } PEnumDescriptor<?> other = (PEnumDescriptor<?>) o; if (!getQualifiedName().equals(other.getQualifiedName()) || getValues().length != other.getValues().length) { return false; } for (PEnumValue<?> value : getValues()) { PEnumValue<?> ovI = other.findById(value.asInteger()); if (ovI != null && !value.asString().equals(ovI.asString())) { return false; } } return true; } PEnumDescriptor(String packageName, String name, Supplier<PEnumBuilder<T>> provider); }
PEnumDescriptor extends PDeclaredDescriptor<T> { @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o.getClass().equals(getClass()))) { return false; } PEnumDescriptor<?> other = (PEnumDescriptor<?>) o; if (!getQualifiedName().equals(other.getQualifiedName()) || getValues().length != other.getValues().length) { return false; } for (PEnumValue<?> value : getValues()) { PEnumValue<?> ovI = other.findById(value.asInteger()); if (ovI != null && !value.asString().equals(ovI.asString())) { return false; } } return true; } PEnumDescriptor(String packageName, String name, Supplier<PEnumBuilder<T>> provider); @Nonnull @Override PType getType(); @Nonnull abstract T[] getValues(); @Nullable abstract T findById(int id); @Nullable abstract T findByName(String name); @Nonnull T valueForId(int id); @Nonnull T valueForName(String name); @Nonnull @Override PEnumBuilder<T> builder(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
PEnumDescriptor extends PDeclaredDescriptor<T> { @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o.getClass().equals(getClass()))) { return false; } PEnumDescriptor<?> other = (PEnumDescriptor<?>) o; if (!getQualifiedName().equals(other.getQualifiedName()) || getValues().length != other.getValues().length) { return false; } for (PEnumValue<?> value : getValues()) { PEnumValue<?> ovI = other.findById(value.asInteger()); if (ovI != null && !value.asString().equals(ovI.asString())) { return false; } } return true; } PEnumDescriptor(String packageName, String name, Supplier<PEnumBuilder<T>> provider); @Nonnull @Override PType getType(); @Nonnull abstract T[] getValues(); @Nullable abstract T findById(int id); @Nullable abstract T findByName(String name); @Nonnull T valueForId(int id); @Nonnull T valueForName(String name); @Nonnull @Override PEnumBuilder<T> builder(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final int DEFAULT_FIRST_VALUE; }