Created
June 1, 2016 10:44
-
-
Save vkoloss/67eae45a7f84dd5b7b53008c84d4f721 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class Person { | |
private String name; | |
private String lastName; | |
private List<String> expertises = new ArrayList<>(); | |
public Person() {} | |
public Person(String name, String lastName) { | |
this.name = name; | |
this.lastName = lastName; | |
} | |
public String getFullName() { | |
return name + ' ' + lastName; | |
} | |
public List<String> getExpertises() { | |
return expertises; | |
} | |
public void add(String e) { | |
expertises.add(e); | |
} | |
public void removeJTech() { | |
expertises = expertises.stream().filter(i -> i.charAt(0) != 'j').collect(Collectors.toList()); | |
} | |
public String getCommaSeparated() { | |
return expertises.stream().collect(Collectors.joining(", ")); | |
} | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) | |
return true; | |
if (o == null || getClass() != o.getClass()) | |
return false; | |
Person person = (Person) o; | |
if (name != null ? !name.equals(person.name) : person.name != null) | |
return false; | |
return lastName != null ? lastName.equals(person.lastName) : person.lastName == null; | |
} | |
@Override | |
public int hashCode() { | |
int result = name != null ? name.hashCode() : 0; | |
result = 31 * result + (lastName != null ? lastName.hashCode() : 0); | |
return result; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment