diff --git a/src/mhtree/MHTree.java b/src/mhtree/MHTree.java index fd57ecbcc5014c4ed9ee4d4064d3abbb5db73a53..10b556dbfec394d8e89e3b73ccf2d703201ef8d5 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;