Last active
January 18, 2019 08:32
-
-
Save peter/b1fc9c808b844b9471e1e3b12f28d969 to your computer and use it in GitHub Desktop.
Java Boilerplate Nostalgia - DTO classes with hashCode, equals, toString, getter/setter methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SettingDTO { | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (!(o instanceof SettingDTO)) return false; | |
SettingDTO filterDTO = (SettingDTO) o; | |
if (key != null ? !key.equals(filterDTO.key) : filterDTO.key != null) return false; | |
if (value != null ? !value.equals(filterDTO.value) : filterDTO.value != null) return false; | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
int result = key != null ? key.hashCode() : 0; | |
result = 31 * result + (value != null ? value.hashCode() : 0); | |
return result; | |
} | |
} | |
private static class Header { | |
private String timestamp; | |
private String eventId; | |
private String eventType; | |
private long customerId; | |
public String getTimestamp() { | |
return timestamp; | |
} | |
public void setTimestamp(String timestamp) { | |
this.timestamp = timestamp; | |
} | |
public String getEventId() { | |
return eventId; | |
} | |
public void setEventId(String eventId) { | |
this.eventId = eventId; | |
} | |
public String getEventType() { | |
return eventType; | |
} | |
public void setEventType(String eventType) { | |
this.eventType = eventType; | |
} | |
public long getCustomerId() { | |
return customerId; | |
} | |
public void setCustomerId(long customerId) { | |
this.customerId = customerId; | |
} | |
@Override | |
public String toString() { | |
return new ToStringBuilder(this) | |
.append("timestamp", timestamp) | |
.append("eventId", eventId) | |
.append("eventType", eventType) | |
.append("customerId", customerId) | |
.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment