Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
PersonGrouping.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.datamodel;
20 
21 import java.util.Objects;
22 import org.sleuthkit.datamodel.Person;
23 
27 public class PersonGrouping implements AutopsyVisitableItem, Comparable<PersonGrouping> {
28 
29  private final Person person;
30 
36  PersonGrouping(Person person) {
37 
38  this.person = person;
39  }
40 
44  Person getPerson() {
45  return person;
46  }
47 
48  @Override
49  public <T> T accept(AutopsyItemVisitor<T> visitor) {
50  return visitor.visit(this);
51  }
52 
53  @Override
54  public int hashCode() {
55  return Objects.hashCode(this.person == null ? 0 : this.person.getPersonId());
56  }
57 
58  @Override
59  public boolean equals(Object obj) {
60  if (this == obj) {
61  return true;
62  }
63  if (obj == null) {
64  return false;
65  }
66  if (getClass() != obj.getClass()) {
67  return false;
68  }
69  final PersonGrouping other = (PersonGrouping) obj;
70  long thisId = (this.getPerson() == null) ? 0 : this.getPerson().getPersonId();
71  long otherId = (other.getPerson() == null) ? 0 : other.getPerson().getPersonId();
72  return thisId == otherId;
73  }
74 
75  /*
76  * Compares two person groupings to be displayed in a list of children under
77  * the root of the tree.
78  */
79  @Override
80  public int compareTo(PersonGrouping o) {
81  String thisPerson = this.getPerson() == null ? null : this.getPerson().getName();
82  String otherPerson = o == null || o.getPerson() == null ? null : o.getPerson().getName();
83 
84  // push unknown host to bottom
85  if (thisPerson == null && otherPerson == null) {
86  return 0;
87  } else if (thisPerson == null) {
88  return 1;
89  } else if (otherPerson == null) {
90  return -1;
91  }
92 
93  return thisPerson.compareToIgnoreCase(otherPerson);
94  }
95 
96 }

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