Some babies are jerks, though...
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.Objects; @JsonPropertyOrder({"key", "name", "cats"}) public class ThingDto<T> { @NotNull() @JsonProperty() private T key; @NotNull() @NotEmpty() @JsonProperty() private String name; @NotNull() @Min(0) @JsonProperty() private int cats; public T getKey() { return key; } public void setKey(T key) { this.key = key; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getCats() { return cats; } public void setCats(int cats) { this.cats = cats; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ThingDto<?> thingDto = (ThingDto<?>) o; return cats == thingDto.cats && Objects.equals(key, thingDto.key) && Objects.equals(name, thingDto.name); } @Override public int hashCode() { return Objects.hash(key, name, cats); } } ThingDto ivy = new ThingDto<String>(); ivy.setKey("value"); ivy.setName("Ivy"); ivy.setCats(0);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Some babies are jerks, though...