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;
36 abstract class AbstractFilterState<FilterType>
implements FilterState<FilterType> {
38 private final SimpleBooleanProperty selected =
new SimpleBooleanProperty(
false);
39 private final SimpleBooleanProperty disabled =
new SimpleBooleanProperty(
false);
40 private final BooleanBinding active = Bindings.and(selected, disabled.not());
41 private final FilterType filter;
44 public FilterType getFilter() {
59 AbstractFilterState(FilterType filter, Boolean selected) {
61 this.selected.set(selected);
65 public BooleanProperty selectedProperty() {
70 public BooleanProperty disabledProperty() {
75 public void setSelected(Boolean act) {
80 public boolean isSelected() {
81 return selected.get();
85 public void setDisabled(Boolean act) {
90 public boolean isDisabled() {
91 return disabledProperty().get();
95 public boolean isActive() {
96 return activeProperty().get();
100 public BooleanExpression activeProperty() {
105 public FilterType getActiveFilter() {
106 return isActive() ? getFilter() : null;
110 public int hashCode() {
112 hash = 37 * hash + Objects.hashCode(this.getFilter());
113 hash = 37 * hash + Objects.hashCode(this.isSelected());
114 hash = 37 * hash + Objects.hashCode(this.isDisabled());
119 public boolean equals(Object obj) {
126 if (getClass() != obj.getClass()) {
129 final AbstractFilterState<?> other = (AbstractFilterState<?>) obj;
130 if (!Objects.equals(
this.getFilter(), other.getFilter())) {
133 if (!Objects.equals(
this.isSelected(), other.isSelected())) {
136 return Objects.equals(this.isDisabled(), other.isDisabled());