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