From bfeaca164e58839880092c868f780391a8566e2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Proch=C3=A1zka?= <david@prochazka.dev>
Date: Thu, 6 May 2021 19:28:27 +0200
Subject: [PATCH] ADD: validation checks on MH-Tree params

---
 src/mhtree/MHTree.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/mhtree/MHTree.java b/src/mhtree/MHTree.java
index fd57ecb..10b556d 100644
--- a/src/mhtree/MHTree.java
+++ b/src/mhtree/MHTree.java
@@ -288,6 +288,22 @@ public class MHTree extends Algorithm implements Serializable {
         private Node root;
 
         public Builder(List<LocalAbstractObject> objects, int bucketCapacity, int arity) {
+            if (objects == null) {
+                throw new NullPointerException("List of objects is null");
+            }
+
+            if (objects.size() < 3) {
+                throw new IllegalArgumentException("Number of objects cannot by smaller than 3");
+            }
+
+            if (bucketCapacity < 3) {
+                throw new IllegalArgumentException("Bucket capacity cannot be smaller than 3");
+            }
+
+            if (arity < 2) {
+                throw new IllegalArgumentException("Arity cannot be smaller than 2");
+            }
+
             this.objects = objects;
             this.bucketCapacity = bucketCapacity;
             this.arity = arity;
-- 
GitLab