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;
29 private long timestamp;
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;
60 public TimeStamp clone() {
61 return new TimeStamp(this.timestamp, this.timestampName);
64 public long getValue() {
65 return this.timestamp;
68 public String getTimeStampName() {
69 return this.timestampName;
73 public int hashCode() {
75 int result = super.hashCode();
76 result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
77 result = prime * result
78 + ((timestampName == null) ? 0 : timestampName.hashCode());
83 public boolean equals(Object obj) {
86 if (!super.equals(obj))
88 if (getClass() != obj.getClass())
90 TimeStamp other = (TimeStamp) obj;
91 if (timestamp != other.timestamp)
93 if (timestampName == null) {
94 if (other.timestampName != null)
96 } else if (!timestampName.equals(other.timestampName))
102 public String toString() {
103 return "TimeStamp[" + timestampName + ": " + timestamp +"]";