diff --git a/Comparison/src/main/java/cz/fidentis/analyst/Project.java b/Comparison/src/main/java/cz/fidentis/analyst/Project.java index 892f547af7e8752b7825528cd31fdffe3401eb09..b39e42d3b00455893e564eb5bd17ac645f974396 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/Project.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/Project.java @@ -18,7 +18,8 @@ public class Project { /** * Returns primary face - * @return primary face + * + * @return HumanFace primary face */ public HumanFace getPrimaryFace() { return primaryFace; @@ -26,15 +27,21 @@ public class Project { /** * Sets new primary face + * * @param primaryFace which will be new primary face + * @throws IllegalArgumentException when argument primaryFace is null */ public void setPrimaryFace(HumanFace primaryFace) { + if (primaryFace == null) { + throw new IllegalArgumentException("Primary face is null"); + } this.primaryFace = primaryFace; } /** - * returns list of HumanFace secondary faces - * @return list of secondary faces in project + * Returns list of HumanFace secondary faces + * + * @return list of secondary faces */ public List<HumanFace> getSecondaryFaces() { return Collections.unmodifiableList(secondaryFaces); @@ -42,27 +49,45 @@ public class Project { /** * Sets new list of secondary faces + * * @param secondaryFaces list of HumanFace which will be new list of * secondary faces + * @throws IllegalArgumentException if one of faces from argument is null */ public void setSecondaryFaces(List<HumanFace> secondaryFaces) { this.secondaryFaces.clear(); + for (int i = 0; i < secondaryFaces.size(); i++) { + if (secondaryFaces.get(i) == null) { + throw new IllegalArgumentException("One of faces is null"); + } + } this.secondaryFaces.addAll(secondaryFaces); } /** * Adds new face to secondaryFaces + * * @param face HumanFace which will be added to list of secondary faces + * @throws IllegalArgumentException when argument face is null */ public void addSecondaryFace(HumanFace face) { + if (face == null) { + throw new IllegalArgumentException("Face is null"); + } this.secondaryFaces.add(face); } /** * Removes HumanFace from secondaryFaces + * * @param face HumanFace which will be removed from secondaryFaces + * @throws IllegalArgumentException when argument face is null */ public void removeSecondaryFace(HumanFace face) { + if (face == null) { + throw new IllegalArgumentException("Face is null"); + } + for (int i = 0; i < secondaryFaces.size(); i++) { if (secondaryFaces.get(i).equals(face)) { secondaryFaces.remove(i);