Skip to content
Snippets Groups Projects
Commit 9a374c6f authored by Matej Kovár's avatar Matej Kovár
Browse files

merged primaryFace and secondaryFaces to just one attribute, models

parent 813aeb3e
No related branches found
No related tags found
No related merge requests found
...@@ -13,14 +13,15 @@ import java.util.List; ...@@ -13,14 +13,15 @@ import java.util.List;
*/ */
public class Project { public class Project {
private HumanFace primaryFace; //private HumanFace primaryFace;
private List<HumanFace> secondaryFaces = new ArrayList<>(); private List<HumanFace> models = new ArrayList<>();
/** /**
* Returns primary face * Returns primary face
* *
* @return HumanFace primary face * @return HumanFace primary face
*/
public HumanFace getPrimaryFace() { public HumanFace getPrimaryFace() {
return primaryFace; return primaryFace;
} }
...@@ -30,7 +31,7 @@ public class Project { ...@@ -30,7 +31,7 @@ public class Project {
* *
* @param primaryFace which will be new primary face * @param primaryFace which will be new primary face
* @throws IllegalArgumentException when argument primaryFace is null * @throws IllegalArgumentException when argument primaryFace is null
*/
public void setPrimaryFace(HumanFace primaryFace) { public void setPrimaryFace(HumanFace primaryFace) {
if (primaryFace == null) { if (primaryFace == null) {
throw new IllegalArgumentException("Primary face is null"); throw new IllegalArgumentException("Primary face is null");
...@@ -40,18 +41,19 @@ public class Project { ...@@ -40,18 +41,19 @@ public class Project {
/** /**
* Removes primary face and sets primaryFace attribute to null * Removes primary face and sets primaryFace attribute to null
*/
public void removePrimaryFace() { public void removePrimaryFace() {
this.primaryFace = null; this.primaryFace = null;
} }*/
/** /**
* Returns list of HumanFace secondary faces * Returns list of HumanFace secondary faces
* *
* @return list of secondary faces * @return list of secondary faces
*/ */
public List<HumanFace> getSecondaryFaces() { public List<HumanFace> getFaces() {
return Collections.unmodifiableList(secondaryFaces); return Collections.unmodifiableList(models);
} }
/** /**
...@@ -61,60 +63,69 @@ public class Project { ...@@ -61,60 +63,69 @@ public class Project {
* secondary faces * secondary faces
* @throws IllegalArgumentException if one of faces from argument is null * @throws IllegalArgumentException if one of faces from argument is null
*/ */
public void setSecondaryFaces(List<HumanFace> secondaryFaces) { public void setFaces(List<HumanFace> secondaryFaces) {
this.secondaryFaces.clear(); this.models.clear();
for (int i = 0; i < secondaryFaces.size(); i++) { for (int i = 0; i < secondaryFaces.size(); i++) {
if (secondaryFaces.get(i) == null) { if (secondaryFaces.get(i) == null) {
throw new IllegalArgumentException("One of faces is null"); throw new IllegalArgumentException("One of faces is null");
} }
} }
this.secondaryFaces.addAll(secondaryFaces); this.models.addAll(secondaryFaces);
} }
/** /**
* Adds new face to secondaryFaces * Adds new face to models
* *
* @param face HumanFace which will be added to list of secondary faces * @param face HumanFace which will be added to list of secondary faces
* @throws IllegalArgumentException when argument face is null * @throws IllegalArgumentException when argument face is null
*/ */
public void addSecondaryFace(HumanFace face) { public void addFace(HumanFace face) {
if (face == null) { if (face == null) {
throw new IllegalArgumentException("Face is null"); throw new IllegalArgumentException("Face is null");
} }
this.secondaryFaces.add(face); this.models.add(face);
} }
/** /**
* Removes HumanFace from secondaryFaces * Removes HumanFace from models
* *
* @param face HumanFace which will be removed from secondaryFaces * @param face HumanFace which will be removed from models
* @throws IllegalArgumentException when argument face is null * @throws IllegalArgumentException when argument face is null
*/ */
public void removeSecondaryFace(HumanFace face) { public void removeFace(HumanFace face) {
if (face == null) { if (face == null) {
throw new IllegalArgumentException("Face is null"); throw new IllegalArgumentException("Face is null");
} }
for (int i = 0; i < secondaryFaces.size(); i++) { for (int i = 0; i < models.size(); i++) {
if (secondaryFaces.get(i).equals(face)) { if (models.get(i).equals(face)) {
secondaryFaces.remove(i); models.remove(i);
} }
} }
} }
/** /**
* Removes faces which are sent to this function by list of HumanFace * Removes faces which are sent to this function by list of HumanFace
* from secondaryFaces * from models
* *
* @param faces List of HumanFace faces which should be removed from * @param faces List of HumanFace faces which should be removed from
* secondaryFaces * models
*/ */
public void removeSelected(List<HumanFace> faces) { public void removeSelected(List<HumanFace> faces) {
for (int i = 0; i < faces.size(); i++) { for (int i = 0; i < faces.size(); i++) {
this.removeSecondaryFace(faces.get(i)); this.removeFace(faces.get(i));
}
}
public HumanFace getFaceByName(String name) {
for (HumanFace face : models) {
if (face.getShortName().equals(name)) {
return face;
}
} }
return null;
} }
/* TODO implement comparable and create comparators for filtering /* TODO implement comparable and create comparators for filtering
secondaryFaces */ models */
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment