Commit | Line | Data |
---|---|---|
9ffcda7d | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2014 École Polytechnique de Montréal |
9ffcda7d GB |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * 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 | |
8 | * | |
9 | * Contributors: | |
10 | * Geneviève Bastien - Initial implementation and API | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.internal.tmf.core.synchronization; |
9ffcda7d | 14 | |
2bdf0193 AM |
15 | import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; |
16 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; | |
9ffcda7d GB |
17 | |
18 | /** | |
19 | * A default simple, identity timestamp transform. It is a singleton class and | |
20 | * returns the timestamp itself | |
21 | * | |
22 | * @author Geneviève Bastien | |
23 | */ | |
ac29c59b | 24 | public final class TmfTimestampTransform implements ITmfTimestampTransformInvertible { |
9ffcda7d GB |
25 | |
26 | /** | |
27 | * Generated serial UID | |
28 | */ | |
29 | private static final long serialVersionUID = -1480581417493073304L; | |
30 | ||
31 | /** | |
32 | * The unique instance of this transform, since it is always the same | |
33 | */ | |
34 | public static final TmfTimestampTransform IDENTITY = new TmfTimestampTransform(); | |
35 | ||
36 | /** | |
37 | * Default constructor | |
38 | */ | |
ac29c59b | 39 | private TmfTimestampTransform() { |
9ffcda7d GB |
40 | |
41 | } | |
42 | ||
43 | @Override | |
44 | public ITmfTimestamp transform(ITmfTimestamp timestamp) { | |
45 | return timestamp; | |
46 | } | |
47 | ||
48 | @Override | |
49 | public long transform(long timestamp) { | |
50 | return timestamp; | |
51 | } | |
52 | ||
53 | @Override | |
54 | public ITmfTimestampTransform composeWith(ITmfTimestampTransform composeWith) { | |
55 | /* Since this transform will not modify anything, return the other */ | |
56 | return composeWith; | |
57 | } | |
58 | ||
59 | @Override | |
60 | public boolean equals(Object other) { | |
61 | return other.getClass().equals(TmfTimestampTransform.class); | |
62 | } | |
63 | ||
64 | @Override | |
65 | public int hashCode() { | |
66 | final int prime = 31; | |
67 | int result = 1; | |
68 | result = (prime * result) + TmfTimestampTransform.class.hashCode(); | |
69 | return result; | |
70 | } | |
71 | ||
72 | @Override | |
73 | public String toString() { | |
74 | return "TmfTimestampTransform [ IDENTITY ]"; //$NON-NLS-1$ | |
75 | } | |
76 | ||
ac29c59b FG |
77 | @Override |
78 | public ITmfTimestampTransform inverse() { | |
79 | return IDENTITY; | |
80 | } | |
81 | ||
9ffcda7d | 82 | } |