1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.trace
;
15 import java
.lang
.reflect
.Method
;
18 * <b><u>TmfLocation</u></b>
20 * A generic implementation of ITmfLocation
22 public class TmfLocation
<L
> implements ITmfLocation
<L
> {
26 @SuppressWarnings("unused")
27 private TmfLocation() {
30 public TmfLocation(L location
) {
34 public TmfLocation(TmfLocation
<L
> other
) {
36 throw new IllegalArgumentException();
37 fLocation
= other
.fLocation
;
40 public void setLocation(L location
) {
44 public L
getLocation() {
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
53 public int hashCode() {
54 if (fLocation
== null)
56 return fLocation
.hashCode();
60 public boolean equals(Object other
) {
61 if (!(other
instanceof TmfLocation
<?
>))
63 TmfLocation
<?
> o
= (TmfLocation
<?
>) other
;
64 if (fLocation
== null)
65 return (o
.fLocation
== null);
66 return fLocation
.equals(o
.fLocation
);
70 public String
toString() {
71 if (fLocation
== null)
73 return fLocation
.toString();
76 @SuppressWarnings("unchecked")
78 public TmfLocation
<L
> clone() {
79 TmfLocation
<L
> clone
= null;
81 clone
= (TmfLocation
<L
>) super.clone();
82 if (this.fLocation
!= null) {
83 Class
<?
> clazz
= this.fLocation
.getClass();
84 Method method
= clazz
.getMethod("clone", new Class
[0]);
85 Object duplic
= method
.invoke(this.fLocation
, new Object
[0]);
86 clone
.fLocation
= (L
) duplic
;
88 } catch (NoSuchMethodException e
) {
89 // exception suppressed
90 } catch (Exception e
) {
91 throw new InternalError(e
.toString());
This page took 0.041591 seconds and 6 git commands to generate.