/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Patrick Tasse - Initial API and implementation
* Francois Chouinard - Put in shape for 1.0
/**
* A convenience class to store trace location arrays. The main purpose is to
* provide a Comparable implementation for TmfExperimentLocation.
- *
+ *
* @version 1.0
* @author Patrick Tasse
*/
// Attributes
// ------------------------------------------------------------------------
- private ITmfLocation<? extends Comparable<?>>[] fLocations;
+ private final ITmfLocation[] fLocations;
// ------------------------------------------------------------------------
// Constructors
/**
* The standard constructor
- *
+ *
* @param locations the locations
*/
- public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) {
+ public TmfLocationArray(ITmfLocation[] locations) {
fLocations = locations;
}
// ------------------------------------------------------------------------
/**
- * The standard constructor
- *
- * @param locations the locations
+ * Get the locations inside this array
+ *
+ * @return the locations
*/
- public ITmfLocation<? extends Comparable<?>>[] getLocations() {
+ public ITmfLocation[] getLocations() {
return fLocations;
}
*/
@Override
public TmfLocationArray clone() {
- ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[fLocations.length];
+ ITmfLocation[] clones = new ITmfLocation[fLocations.length];
for (int i = 0; i < fLocations.length; i++) {
- clones[i] = fLocations[i].clone();
+ ITmfLocation location = fLocations[i];
+ clones[i] = (location != null) ? location.clone() : null;
}
return new TmfLocationArray(clones);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public int compareTo(TmfLocationArray o) {
for (int i = 0; i < fLocations.length; i++) {
- ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) fLocations[i].getLocation();
- ITmfLocation<? extends Comparable> l2 = (ITmfLocation<? extends Comparable>) o.fLocations[i].getLocation();
- int result = l1.getLocation().compareTo(l2.getLocation());
+ Comparable l1 = fLocations[i].getLocationData();
+ Comparable l2 = o.fLocations[i].getLocationData();
+ int result = l1.compareTo(l2);
if (result != 0) {
return result;
}