From 477e282c10c0cf7f8e23aa3157c895f64ccece9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Kov=C3=A1r?= <matko@192.168.1.105>
Date: Wed, 14 Apr 2021 09:17:43 +0200
Subject: [PATCH] fixed javadocs, added checks whether method inputs are valid
 or not

---
 .../java/cz/fidentis/analyst/Project.java     | 31 +++++++++++++++++--
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/Comparison/src/main/java/cz/fidentis/analyst/Project.java b/Comparison/src/main/java/cz/fidentis/analyst/Project.java
index 892f547a..b39e42d3 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);
-- 
GitLab