Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractFilterState.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.ui.filtering.datamodel;
20 
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;
27 
36 abstract class AbstractFilterState<FilterType> implements FilterState<FilterType> {
37 
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;
42 
43  @Override
44  public FilterType getFilter() {
45  return filter;
46  }
47 
59  AbstractFilterState(FilterType filter, Boolean selected) {
60  this.filter = filter;
61  this.selected.set(selected);
62  }
63 
64  @Override
65  public BooleanProperty selectedProperty() {
66  return selected;
67  }
68 
69  @Override
70  public BooleanProperty disabledProperty() {
71  return disabled;
72  }
73 
74  @Override
75  public void setSelected(Boolean act) {
76  selected.set(act);
77  }
78 
79  @Override
80  public boolean isSelected() {
81  return selected.get();
82  }
83 
84  @Override
85  public void setDisabled(Boolean act) {
86  disabled.set(act);
87  }
88 
89  @Override
90  public boolean isDisabled() {
91  return disabledProperty().get();
92  }
93 
94  @Override
95  public boolean isActive() {
96  return activeProperty().get();
97  }
98 
99  @Override
100  public BooleanExpression activeProperty() {
101  return active;
102  }
103 
104  @Override
105  public FilterType getActiveFilter() {
106  return isActive() ? getFilter() : null;
107  }
108 
109  @Override
110  public int hashCode() {
111  int hash = 7;
112  hash = 37 * hash + Objects.hashCode(this.getFilter());
113  hash = 37 * hash + Objects.hashCode(this.isSelected());
114  hash = 37 * hash + Objects.hashCode(this.isDisabled());
115  return hash;
116  }
117 
118  @Override
119  public boolean equals(Object obj) {
120  if (this == obj) {
121  return true;
122  }
123  if (obj == null) {
124  return false;
125  }
126  if (getClass() != obj.getClass()) {
127  return false;
128  }
129  final AbstractFilterState<?> other = (AbstractFilterState<?>) obj;
130  if (!Objects.equals(this.getFilter(), other.getFilter())) {
131  return false;
132  }
133  if (!Objects.equals(this.isSelected(), other.isSelected())) {
134  return false;
135  }
136  return Objects.equals(this.isDisabled(), other.isDisabled());
137  }
138 
139 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Jul 8 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.