// Path: src/main/java/de/danielbasedow/prospecter/core/MatchCondition.java
// public enum MatchCondition {
//     EQUALS,
//     LESS_THAN,
//     GREATER_THAN,
//     LESS_THAN_EQUALS,
//     GREATER_THAN_EQUALS,
//     NONE,
//     IN,
//     RADIUS
// }
// 
// Path: src/main/java/de/danielbasedow/prospecter/core/Token.java
// public class Token<T> {
//     private final T token;
//     private final MatchCondition condition;
// 
//     public Token(T token) {
//         this(token, MatchCondition.NONE);
//     }
// 
//     public Token(T token, MatchCondition condition) {
//         this.token = token;
//         this.condition = condition;
//     }
// 
//     public T getToken() {
//         return token;
//     }
// 
//     public int hashCode() {
//         return token.hashCode();
//     }
// 
//     public boolean equals(Object compare) {
//         if (compare instanceof Token) {
//             return token.equals(((Token) compare).getToken());
//         }
//         return false;
//     }
// 
//     public MatchCondition getCondition() {
//         return condition;
//     }
// }
// 
// Path: src/main/java/de/danielbasedow/prospecter/core/query/Condition.java
// public class Condition implements ClauseNode {
//     private final String fieldName;
//     private final Token token;
// 
//     /**
//      * if "not" is set the condition will result in a posting in a "NOT-index"
//      */
//     private boolean not;
// 
//     public Condition(String fieldName, Token token) {
//         this.fieldName = fieldName;
//         this.token = token;
//         this.not = false;
//     }
// 
//     public Condition(String fieldName, Token token, boolean not) {
//         this.fieldName = fieldName;
//         this.token = token;
//         this.not = not;
//     }
// 
//     public String getFieldName() {
//         return fieldName;
//     }
// 
//     public Token getToken() {
//         return token;
//     }
// 
//     public boolean isNot() {
//         return not;
//     }
// 
//     public void setNot(boolean not) {
//         this.not = not;
//     }
// 
//     @Override
//     public boolean isLeaf() {
//         return true;
//     }
// 
//     /**
//      * AIMA symbols need a unique, java conform name
//      *
//      * @return symbol name for use in AIMA
//      */
//     public String getSymbolName() {
//         return fieldName + token.getCondition().name() + token.getToken().toString();
//     }
// }


import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.danielbasedow.prospecter.core.MatchCondition;
import de.danielbasedow.prospecter.core.Token;
import de.danielbasedow.prospecter.core.query.Condition;
import java.util.ArrayList;
import java.util.List;
package de.danielbasedow.prospecter.core.query.build;



public abstract class GenericFieldHandler extends AbstractFieldHandler {

    public GenericFieldHandler(ObjectNode node, String fieldName) {
        super(node, fieldName);
    }

    public List<ClauseNode> getConditions() {
        List<ClauseNode> conditions = new ArrayList<ClauseNode>();

        String comparator = root.get("condition").asText();
        MatchCondition matchCondition = getMatchCondition(comparator);

        boolean not = false;
        if (root.get("not") != null) {
            not = root.get("not").asBoolean(false);
        }

        JsonNode valNode = getValue();

        if (valNode.getNodeType() == JsonNodeType.ARRAY) {
            List<Token> tokens = new ArrayList<Token>();
            for (JsonNode node : valNode) {
                tokens.add(getToken(node, matchCondition));
            }
            conditions.add(new Condition(fieldName, new Token<List<Token>>(tokens, MatchCondition.IN), not));
        } else {
// Path: src/main/java/de/danielbasedow/prospecter/core/MatchCondition.java
// public enum MatchCondition {
//     EQUALS,
//     LESS_THAN,
//     GREATER_THAN,
//     LESS_THAN_EQUALS,
//     GREATER_THAN_EQUALS,
//     NONE,
//     IN,
//     RADIUS
// }
// 
// Path: src/main/java/de/danielbasedow/prospecter/core/Token.java
// public class Token<T> {
//     private final T token;
//     private final MatchCondition condition;
// 
//     public Token(T token) {
//         this(token, MatchCondition.NONE);
//     }
// 
//     public Token(T token, MatchCondition condition) {
//         this.token = token;
//         this.condition = condition;
//     }
// 
//     public T getToken() {
//         return token;
//     }
// 
//     public int hashCode() {
//         return token.hashCode();
//     }
// 
//     public boolean equals(Object compare) {
//         if (compare instanceof Token) {
//             return token.equals(((Token) compare).getToken());
//         }
//         return false;
//     }
// 
//     public MatchCondition getCondition() {
//         return condition;
//     }
// }
// 
// Path: src/main/java/de/danielbasedow/prospecter/core/query/Condition.java
// public class Condition implements ClauseNode {
//     private final String fieldName;
//     private final Token token;
// 
//     /**
//      * if "not" is set the condition will result in a posting in a "NOT-index"
//      */
//     private boolean not;
// 
//     public Condition(String fieldName, Token token) {
//         this.fieldName = fieldName;
//         this.token = token;
//         this.not = false;
//     }
// 
//     public Condition(String fieldName, Token token, boolean not) {
//         this.fieldName = fieldName;
//         this.token = token;
//         this.not = not;
//     }
// 
//     public String getFieldName() {
//         return fieldName;
//     }
// 
//     public Token getToken() {
//         return token;
//     }
// 
//     public boolean isNot() {
//         return not;
//     }
// 
//     public void setNot(boolean not) {
//         this.not = not;
//     }
// 
//     @Override
//     public boolean isLeaf() {
//         return true;
//     }
// 
//     /**
//      * AIMA symbols need a unique, java conform name
//      *
//      * @return symbol name for use in AIMA
//      */
//     public String getSymbolName() {
//         return fieldName + token.getCondition().name() + token.getToken().toString();
//     }
// }


// Path: src/main/java/de/danielbasedow/prospecter/core/query/build/GenericFieldHandler.java
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.danielbasedow.prospecter.core.MatchCondition;
import de.danielbasedow.prospecter.core.Token;
import de.danielbasedow.prospecter.core.query.Condition;
import java.util.ArrayList;
import java.util.List;

package de.danielbasedow.prospecter.core.query.build;



public abstract class GenericFieldHandler extends AbstractFieldHandler {

    public GenericFieldHandler(ObjectNode node, String fieldName) {
        super(node, fieldName);
    }

    public List<ClauseNode> getConditions() {
        List<ClauseNode> conditions = new ArrayList<ClauseNode>();

        String comparator = root.get("condition").asText();
        MatchCondition matchCondition = getMatchCondition(comparator);

        boolean not = false;
        if (root.get("not") != null) {
            not = root.get("not").asBoolean(false);
        }

        JsonNode valNode = getValue();

        if (valNode.getNodeType() == JsonNodeType.ARRAY) {
            List<Token> tokens = new ArrayList<Token>();
            for (JsonNode node : valNode) {
                tokens.add(getToken(node, matchCondition));
            }
            conditions.add(new Condition(fieldName, new Token<List<Token>>(tokens, MatchCondition.IN), not));
        } else {
            conditions.add(new Condition(fieldName, getToken(valNode, matchCondition), not));