package org.cobbzilla.wizard.model.search;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import static org.cobbzilla.util.daemon.ZillaRuntime.empty;
import static org.cobbzilla.util.reflect.ReflectionUtil.copy;
import static org.cobbzilla.util.reflect.ReflectionUtil.instantiate;

@NoArgsConstructor @AllArgsConstructor @Accessors(chain=true)
public class SearchBound {

    @Getter @Setter private String name;
    @Getter @Setter private SearchBoundComparison comparison;

    @Getter @Setter private SearchFieldType type;

    public SearchBound(SearchBound bound) { copy(this, bound); }

    public boolean hasType () { return type != null; }

    @Getter @Setter private String[] params;
    public boolean hasParams () { return !empty(params); }

    @Getter @Setter @JsonIgnore private String processorClass;
    public boolean hasProcessor () { return !empty(processorClass); }

    @JsonIgnore public <T extends CustomSearchBoundProcessor> T getProcessor() { return instantiate(processorClass); }

}

@@ -521,16 +521,82 @@
 ound %7B%0A%0A
+    public SearchBound(SearchBound bound) %7B copy(this, bound); %7D%0A%0A
     @Get
@@ -745,75 +745,8 @@
 pe;%0A
-%0A    public SearchBound(SearchBound bound) %7B copy(this, bound); %7D%0A%0A
     

move constructor to top