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;
15 import org.apache.commons.lang3.builder.EqualsBuilder;
16 import org.apache.commons.lang3.builder.HashCodeBuilder;
19 * @file TimeStamp.java
21 * @brief Class representing a TimeStamp
23 * A property describing a timestamp based following the rules of
24 * java.util.Date, also given the time stamp represent the time when
25 * something happened, then a name is attached to this property so
26 * to qualify what are we talking about
29 public class TimeStamp extends Property {
30 private static final long serialVersionUID = 1L;
32 private long timestamp;
34 private String timestampName;
36 public static final String TimeStampPropName = "timeStamp";
39 * Construct a TimeStamp proporty
41 * @param timestamp the time stampt we want to describe in "epoch"
42 * format following the rules of java.util.Date
43 * @param timestampName A qualifier for the timestamp, for example
44 * "JoinTime" or any even qualifier could come up
46 * @return Constructed object
48 public TimeStamp(long timestamp, String timestampName) {
49 super(TimeStampPropName);
50 this.timestamp = timestamp;
51 this.timestampName = timestampName;
55 * Private constructor used for JAXB mapping
58 super(TimeStampPropName);
60 this.timestampName = null;
63 public TimeStamp clone() {
64 return new TimeStamp(this.timestamp, this.timestampName);
67 public long getValue() {
68 return this.timestamp;
71 public String getTimeStampName() {
72 return this.timestampName;
76 public int hashCode() {
77 return HashCodeBuilder.reflectionHashCode(this);
81 public boolean equals(Object obj) {
82 return EqualsBuilder.reflectionEquals(this, obj);
86 public String toString() {
87 return "TimeStamp[" + timestampName + ": " + timestamp +"]";