Skip to content

Commit

Permalink
Add equals and hashcode overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Anshul Singh committed Jan 16, 2025
1 parent 9f3463c commit d1895d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ protected void validateUpdate(NamespaceConfigurationApi existing,
NamespaceConfigurationApi updated) {
if (!Objects.equals(existing.getId(), updated.getId()) ||
!Objects.equals(existing.getAuth().getNamespace(), updated.getAuth().getNamespace()) ||
!Objects.equals(existing.getQuotasConfiguration().getTaskQuotasConfiguration().getMaximumDetectionTasksPerMonth(),
updated.getQuotasConfiguration().getTaskQuotasConfiguration().getMaximumNotificationTasksPerMonth()) ||
!Objects.equals(existing.getQuotasConfiguration().getTaskQuotasConfiguration().getMaximumNotificationTasksPerMonth(),
updated.getQuotasConfiguration().getTaskQuotasConfiguration().getMaximumNotificationTasksPerMonth())) {
!Objects.equals(existing.getQuotasConfiguration(), updated.getQuotasConfiguration())) {
throw badRequest(
ThirdEyeStatus.ERR_NAMESPACE_CONFIGURATION_VALIDATION_FAILED,
existing.namespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package ai.startree.thirdeye.spi.api;

import java.util.Objects;

public class TaskQuotasConfigurationApi {

private Long maximumDetectionTasksPerMonth;
Expand All @@ -37,4 +39,23 @@ public TaskQuotasConfigurationApi setMaximumNotificationTasksPerMonth(
this.maximumNotificationTasksPerMonth = maximumNotificationTasksPerMonth;
return this;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final TaskQuotasConfigurationApi that = (TaskQuotasConfigurationApi) o;
return Objects.equals(maximumDetectionTasksPerMonth, that.maximumDetectionTasksPerMonth)
&& Objects.equals(maximumNotificationTasksPerMonth,
that.maximumNotificationTasksPerMonth);
}

@Override
public int hashCode() {
return Objects.hash(maximumDetectionTasksPerMonth, maximumNotificationTasksPerMonth);
}
}

0 comments on commit d1895d4

Please sign in to comment.