package com.bardframework.bard.core.doc;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;

import java.util.HashMap;
import java.util.Map;

public class DocParameter implements Comparable<DocParameter> {
    @JsonProperty(value = "name")
    public String name;

    @JsonProperty(value = "description")
    public String description;

    @JsonProperty(value = "belongs")
    public String belongs;

    @JsonIgnore
    public Class<?> type;

    @JsonProperty(value = "limitations")
    public Map<String, Object> limitations = new HashMap<>();

    @JsonProperty(value = "schema")
    public JsonSchema getType() throws JsonMappingException {
        return Document.toJsonSchema(type);
    }

    @Override public int compareTo(DocParameter o) {
        boolean equal =
            ((o.name == null && name == null) || o.name.equals(name)) &&
                ((o.belongs == null && belongs == null) || o.belongs.equals(belongs)) &&
                ((o.description == null && description == null) || o.description
                    .equals(description));
        if (equal) {
            return 0;
        }
        return 1;
    }

    @JsonIgnore
    public boolean isNull() {
        return name == null && description == null;
    }
}

@@ -932,156 +932,53 @@
     
-boolean equal =%0A            ((o.name == null && name == null) %7C%7C o.name.equals(name)) &&%0A                ((o.belongs == null && belongs == null) %7C%7C 
+if (equal(o.name, name) &&%0A            equal(
 o.be
@@ -986,24 +986,18 @@
 ongs
-.equals(
+, 
 belongs)
 ) &&
@@ -992,17 +992,16 @@
 belongs)
-)
  &&%0A    
@@ -1012,137 +1012,41 @@
     
-    ((o.description == null && description == null) %7C%7C o.description%0A                    .equals(description));%0A        if (equal
+equal(o.description, description)
 ) %7B%0A
@@ -1205,11 +1205,133 @@
 l;%0A    %7D
+%0A%0A    private boolean equal(String a, String b) %7B%0A        return a == null && b == null %7C%7C a != null && a.equals(b);%0A    %7D
 %0A%7D%0A

fix code style