Autopsy  4.12.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 
32 abstract class AbstractFilterState<F> implements FilterState<F> {
33 
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;
38 
39  @Override
40  public F getFilter() {
41  return filter;
42  }
43 
44  AbstractFilterState(F filter, Boolean select) {
45  this.filter = filter;
46  selected.set(select);
47  }
48 
49  @Override
50  public BooleanProperty selectedProperty() {
51  return selected;
52  }
53 
54  @Override
55  public BooleanProperty disabledProperty() {
56  return disabled;
57  }
58 
59  @Override
60  public void setSelected(Boolean act) {
61  selected.set(act);
62  }
63 
64  @Override
65  public boolean isSelected() {
66  return selected.get();
67  }
68 
69  @Override
70  public void setDisabled(Boolean act) {
71  disabled.set(act);
72  }
73 
74  @Override
75  public boolean isDisabled() {
76  return disabledProperty().get();
77  }
78 
79  @Override
80  public boolean isActive() {
81  return activeProperty().get();
82  }
83 
84  @Override
85  public BooleanExpression activeProperty() {
86  return activeProp;
87  }
88 
89  @Override
90  public F getActiveFilter() {
91  return isActive() ? getFilter() : null;
92  }
93 
94  @Override
95  public int hashCode() {
96  int hash = 7;
97  hash = 37 * hash + Objects.hashCode(this.getFilter());
98  hash = 37 * hash + Objects.hashCode(this.isSelected());
99  hash = 37 * hash + Objects.hashCode(this.isDisabled());
100  return hash;
101  }
102 
103  @Override
104  public boolean equals(Object obj) {
105  if (this == obj) {
106  return true;
107  }
108  if (obj == null) {
109  return false;
110  }
111  if (getClass() != obj.getClass()) {
112  return false;
113  }
114  final AbstractFilterState<?> other = (AbstractFilterState<?>) obj;
115  if (!Objects.equals(this.getFilter(), other.getFilter())) {
116  return false;
117  }
118  if (!Objects.equals(this.isSelected(), other.isSelected())) {
119  return false;
120  }
121  return Objects.equals(this.isDisabled(), other.isDisabled());
122  }
123 }

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.