Added methods hashCode() and equals() for models
This commit is contained in:
parent
3b89c79540
commit
0104db48f5
@ -28,4 +28,19 @@ public class Bucket {
|
||||
if (slots.isUnlimited()) return true;
|
||||
return slots.getSlots() >= usedSlots + requiredSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return identifier.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) return true;
|
||||
if (object == null) return false;
|
||||
if (object instanceof Bucket other) {
|
||||
return identifier.equals(other.identifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,4 +2,20 @@ package ru.dragonestia.loadbalancer.model;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public record User(@NonNull String identifier) {}
|
||||
public record User(@NonNull String identifier) {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return identifier.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) return true;
|
||||
if (object == null) return false;
|
||||
if (object instanceof User other) {
|
||||
return identifier.equals(other.identifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user