Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Created July 24, 2020 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theboreddev/810e21e9f936b60d1dc00cab115dc519 to your computer and use it in GitHub Desktop.
Save theboreddev/810e21e9f936b60d1dc00cab115dc519 to your computer and use it in GitHub Desktop.
address
import java.util.Objects;
public class Address {
private final String firstLine;
private final String secondLine;
private final String postCode;
public Address(String firstLine, String secondLine, String postCode) {
this.firstLine = firstLine;
this.secondLine = secondLine;
this.postCode = postCode;
}
public String getFirstLine() {
return firstLine;
}
public String getSecondLine() {
return secondLine;
}
public String getPostCode() {
return postCode;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Address address = (Address) o;
return Objects.equals(firstLine, address.firstLine) &&
Objects.equals(secondLine, address.secondLine) &&
Objects.equals(postCode, address.postCode);
}
@Override
public int hashCode() {
return Objects.hash(firstLine, secondLine, postCode);
}
@Override
public String toString() {
return "Address{" +
"firstLine='" + firstLine + '\'' +
", secondLine='" + secondLine + '\'' +
", postCode='" + postCode + '\'' +
'}';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment