// Path: src/main/java/ru/taximaxim/treeviewer/utils/TriFunction.java
// @FunctionalInterface
// public interface TriFunction<A,B,C,R> {
// 
//     R apply(A a, B b, C c);
// 
//     default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
//         Objects.requireNonNull(after);
//         return (A a, B b, C c) -> after.apply(apply(a, b, c));
//     }
// }


import ru.taximaxim.treeviewer.utils.TriFunction;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
/*-
 * ========================LICENSE_START=================================
 * pgSqlBlocks
 * %
 * Copyright (C) 2017 - 2018 "Technology" LLC
 * %
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */
package ru.taximaxim.treeviewer.filter;



/**
 * Enum for types of column filters
 */
enum FilterOperation {

    NONE("", (o, s, t) -> true),
    EQUALS("=", FilterOperation::equalsByType),
    NOT_EQUALS("!=", (o, s, t) -> !EQUALS.matchesForType(o, s, t)),
    CONTAINS("~", (o, s, t) -> o.toLowerCase().contains(s.toLowerCase())),
    GREATER(">", FilterOperation::greater),
    GREATER_OR_EQUAL(">=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || GREATER.matchesForType(o, s, t)),
    LESS("<", FilterOperation::less),
    LESS_OR_EQUAL("<=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || LESS.matchesForType(o, s, t));

    private final String conditionText;
    private final TriFunction<String, String, ColumnType, Boolean> matcherFunction;

// Path: src/main/java/ru/taximaxim/treeviewer/utils/TriFunction.java
// @FunctionalInterface
// public interface TriFunction<A,B,C,R> {
// 
//     R apply(A a, B b, C c);
// 
//     default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
//         Objects.requireNonNull(after);
//         return (A a, B b, C c) -> after.apply(apply(a, b, c));
//     }
// }


// Path: src/main/java/ru/taximaxim/treeviewer/filter/FilterOperation.java
import ru.taximaxim.treeviewer.utils.TriFunction;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;

/*-
 * ========================LICENSE_START=================================
 * pgSqlBlocks
 * %
 * Copyright (C) 2017 - 2018 "Technology" LLC
 * %
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */
package ru.taximaxim.treeviewer.filter;



/**
 * Enum for types of column filters
 */
enum FilterOperation {

    NONE("", (o, s, t) -> true),
    EQUALS("=", FilterOperation::equalsByType),
    NOT_EQUALS("!=", (o, s, t) -> !EQUALS.matchesForType(o, s, t)),
    CONTAINS("~", (o, s, t) -> o.toLowerCase().contains(s.toLowerCase())),
    GREATER(">", FilterOperation::greater),
    GREATER_OR_EQUAL(">=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || GREATER.matchesForType(o, s, t)),
    LESS("<", FilterOperation::less),
    LESS_OR_EQUAL("<=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || LESS.matchesForType(o, s, t));

    private final String conditionText;
    private final TriFunction<String, String, ColumnType, Boolean> matcherFunction;

    FilterOperation(String conditionText, TriFunction<String, String, ColumnType, Boolean> matcherFunction) {