1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
17 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.equalsNullable
;
20 * File and name internal helper class <br>
21 * it has the file, a name to display, whether the name is conflicting and a
22 * reference to the configuration element defining its trace type.
24 * @author Matthew Khouzam
26 class FileAndName
implements Comparable
<FileAndName
> {
28 final private File fFile
;
29 private String fTraceTypeId
;
31 private boolean fConflict
;
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
41 * the file, can only be set here
43 * the name, can be renamed
46 public FileAndName(File f
, String n
) {
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
61 public String
getName() {
71 public void setName(String name
) {
76 * Sets the configuration element of the
81 public void setTraceTypeId(String elem
) {
86 * Gets the configuration element canonical name
88 * @return gets the configuration element canonical name
90 public String
getTraceTypeId() {
99 public File
getFile() {
104 * Set that the name is conflicting or not
107 * if the name is conflicting or not
109 public void setConflictingName(boolean conflict
) {
110 fConflict
= conflict
;
114 * Is the name conflicting?
116 * @return is the name conflicting?
118 public boolean isConflictingName() {
123 * Is the fileAndName renamed
125 * @return true if the name does not match the filename
127 public boolean isRenamed() {
128 return !fName
.equals(fFile
.getName());
131 // ------------------------------------------------------------------------
132 // Comparator & Equals
133 // ------------------------------------------------------------------------
136 public int compareTo(FileAndName o
) {
137 int retVal
= getFile().compareTo(o
.getFile());
139 if (getTraceTypeId() != null) {
140 if (getTraceTypeId() != null) {
141 if (o
.getTraceTypeId() != null) {
142 retVal
= getTraceTypeId().compareTo(o
.getTraceTypeId());
151 public int hashCode() {
152 // do not take "name" into account since it can change on the fly.
153 final int prime
= 31;
155 result
= prime
* result
+ ((fTraceTypeId
== null) ?
0 : fTraceTypeId
.hashCode());
156 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.hashCode());
161 public boolean equals(Object obj
) {
162 // do not take "name" into account since it can change on the fly.
169 if (!(obj
instanceof FileAndName
)) {
172 FileAndName other
= (FileAndName
) obj
;
173 if (!equalsNullable(fTraceTypeId
, other
.fTraceTypeId
)) {
176 if (!equalsNullable(fFile
, other
.fFile
)) {
This page took 0.034502 seconds and 5 git commands to generate.