Sha256: 3de4e96399fe60365220ab971eb9fed43052ab3bef046af0e2070d399882d0d9
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
package org.embulk.filter.row; public class BooleanCondition implements Condition { private BooleanComparator comparator; @FunctionalInterface interface BooleanComparator { boolean compare(Boolean subject); } public BooleanCondition(String operator, Boolean argument, boolean not) { BooleanComparator comparator; switch (operator.toUpperCase()) { case "IS NULL": comparator = (Boolean subject) -> { return subject == null; }; break; case "IS NOT NULL": comparator = (Boolean subject) -> { return subject != null; }; break; case "!=": comparator = (Boolean subject) -> { return subject == null ? true : !subject.equals(argument); }; break; default: // case "==": comparator = (Boolean subject) -> { return subject == null ? false : subject.equals(argument); }; break; } this.comparator = comparator; if (not) this.comparator = (Boolean subject) -> { return !comparator.compare(subject); }; } public boolean compare(Boolean subject) { return this.comparator.compare(subject); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
embulk-filter-row-0.1.1 | src/main/java/org/embulk/filter/row/BooleanCondition.java |
embulk-filter-row-0.1.0 | src/main/java/org/embulk/filter/row/BooleanCondition.java |