Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author lmoentje
- */
- import java.io.Serializable;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.Objects;
- public class Account implements Serializable {
- private static final long serialVersionUID = 19;
- private String firstName;
- private String lastName;
- private String gender;
- private String email;
- private String login;
- private String password;
- private HashSet<Account> friends;
- private HashSet<Post> wall;
- private HashSet<Integer> likes;
- public Account(String firstName, String lastName, String gender, String email, String login, String password) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.gender = gender;
- this.email = email;
- this.login = login;
- this.password = password;
- this.friends = new HashSet<>();
- this.wall = new HashSet<>();
- this.likes = new HashSet<>();
- }
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(String lastNamen) {
- this.lastName = lastNamen;
- }
- public String getGender() {
- return gender;
- }
- public void setGender(String gender) {
- this.gender = gender;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getLogin() {
- return login;
- }
- public void setLogin(String login) {
- this.login = login;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public HashSet<Account> getFriends() {
- return friends;
- }
- public HashSet<Post> getWall() {
- return wall;
- }
- public HashSet<Integer> getLikes() {
- return likes;
- }
- @Override
- public String toString() {
- return (this.getFirstName()+" "+this.getLastName()+" ("+getFriends().size()+" vrienden)");
- }
- public String getCSV(){
- return firstName+";"+lastName+";"+gender+";"+email+";"+login+";"+password;
- }
- //OMP: SPECIALE EQUALS!!
- @Override
- public boolean equals(Object obj) {
- boolean isEqual = false;
- if((obj!=null)&&(obj instanceof Account)){
- final Account other = (Account) obj;
- if (!Objects.equals(this.firstName, other.firstName)) {
- return false;
- }
- if (!Objects.equals(this.lastName, other.lastName)) {
- return false;
- }
- if (!Objects.equals(this.gender, other.gender)) {
- return false;
- }
- if (!Objects.equals(this.email, other.email)) {
- return false;
- }
- if (!Objects.equals(this.login, other.login)) {
- return false;
- }
- if (!Objects.equals(this.password, other.password)) {
- return false;
- }
- if (!Objects.equals(this.likes, other.likes)) {
- return false;
- }
- if (!equalsFriends(other)){
- return false;
- }
- if (!equalsWall(other)) {
- return false;
- }
- return true;
- }
- return isEqual;
- }
- public boolean equalsFriends(Object o){
- Account acc = (Account) o;
- boolean a = true;
- boolean b = true;
- for(Account vriendA : acc.friends){
- boolean found = false;
- for(Account vriendB : this.friends){
- if(vriendA.getLogin().equals(vriendB.getLogin()))
- found = true;
- }
- if (!found){
- return false;
- }
- }
- for(Account vriendA : this.friends){
- boolean found = false;
- for(Account vriendB : acc.friends){
- if(vriendA.getLogin().equals(vriendB.getLogin()))
- found = true;
- }
- if(!found)
- return false;
- }
- return true;
- }
- public boolean equalsWall(Object o){
- Account acc = (Account) o;
- boolean a = true;
- boolean b = true;
- for(Post post : acc.wall){
- boolean found = false;
- for(Post postB : this.wall){
- if(post.getPostID().equals(postB.getPostID()))
- found = true;
- }
- if (!found){
- return false;
- }
- }
- for(Post post : this.wall){
- boolean found = false;
- for(Post postB : acc.wall){
- if(post.getPostID().equals(postB.getPostID()))
- found = true;
- }
- if(!found)
- return false;
- }
- return true;
- }
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 97 * hash + Objects.hashCode(this.firstName);
- hash = 97 * hash + Objects.hashCode(this.lastName);
- hash = 97 * hash + Objects.hashCode(this.gender);
- hash = 97 * hash + Objects.hashCode(this.email);
- hash = 97 * hash + Objects.hashCode(this.login);
- hash = 97 * hash + Objects.hashCode(this.password);
- return hash;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement