3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.core;
12 import javax.xml.bind.annotation.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
16 * @file TimeStamp.java
18 * @brief Class representing a TimeStamp
20 * A property describing a timestamp based following the rules of
21 * java.util.Date, also given the time stamp represent the time when
22 * something happened, then a name is attached to this property so
23 * to qualify what are we talking about
26 public class TimeStamp extends Property {
27 private static final long serialVersionUID = 1L;
28 @XmlElement(name = "value")
29 private long timestamp;
30 @XmlElement(name = "name")
31 private String timestampName;
33 public static final String TimeStampPropName = "timeStamp";
36 * Construct a TimeStamp proporty
38 * @param timestamp the time stampt we want to describe in "epoch"
39 * format following the rules of java.util.Date
40 * @param timestampName A qualifier for the timestamp, for example
41 * "JoinTime" or any even qualifier could come up
43 * @return Constructed object
45 public TimeStamp(long timestamp, String timestampName) {
46 super(TimeStampPropName);
47 this.timestamp = timestamp;
48 this.timestampName = timestampName;
52 * Private constructor used for JAXB mapping
55 super(TimeStampPropName);
57 this.timestampName = null;
61 public TimeStamp clone() {
62 return new TimeStamp(this.timestamp, this.timestampName);
65 public long getValue() {
66 return this.timestamp;
69 public String getTimeStampName() {
70 return this.timestampName;
74 public int hashCode() {
76 int result = super.hashCode();
77 result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
78 result = prime * result
79 + ((timestampName == null) ? 0 : timestampName.hashCode());
84 public boolean equals(Object obj) {
87 if (!super.equals(obj))
89 if (getClass() != obj.getClass())
91 TimeStamp other = (TimeStamp) obj;
92 if (timestamp != other.timestamp)
94 if (timestampName == null) {
95 if (other.timestampName != null)
97 } else if (!timestampName.equals(other.timestampName))
103 public String toString() {
104 return "TimeStamp[" + timestampName + ": " + timestamp +"]";