19 package org.sleuthkit.autopsy.timeline.ui.filtering.datamodel;
21 import java.util.Objects;
22 import javafx.beans.binding.Bindings;
23 import javafx.beans.binding.BooleanBinding;
24 import javafx.beans.binding.BooleanExpression;
25 import javafx.beans.property.BooleanProperty;
26 import javafx.beans.property.SimpleBooleanProperty;
32 abstract class AbstractFilterState<F>
implements FilterState<F> {
34 private final SimpleBooleanProperty selected =
new SimpleBooleanProperty(
false);
35 private final SimpleBooleanProperty disabled =
new SimpleBooleanProperty(
false);
36 private final BooleanBinding activeProp = Bindings.and(selected, disabled.not());
37 private final F filter;
40 public F getFilter() {
44 AbstractFilterState(F filter, Boolean select) {
50 public BooleanProperty selectedProperty() {
55 public BooleanProperty disabledProperty() {
60 public void setSelected(Boolean act) {
65 public boolean isSelected() {
66 return selected.get();
70 public void setDisabled(Boolean act) {
75 public boolean isDisabled() {
76 return disabledProperty().get();
80 public boolean isActive() {
81 return activeProperty().get();
85 public BooleanExpression activeProperty() {
90 public F getActiveFilter() {
91 return isActive() ? getFilter() : null;
95 public int hashCode() {
97 hash = 37 * hash + Objects.hashCode(this.getFilter());
98 hash = 37 * hash + Objects.hashCode(this.isSelected());
99 hash = 37 * hash + Objects.hashCode(this.isDisabled());
104 public boolean equals(Object obj) {
111 if (getClass() != obj.getClass()) {
114 final AbstractFilterState<?> other = (AbstractFilterState<?>) obj;
115 if (!Objects.equals(
this.getFilter(), other.getFilter())) {
118 if (!Objects.equals(
this.isSelected(), other.isSelected())) {
121 return Objects.equals(this.isDisabled(), other.isDisabled());