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 org.apache.commons.lang3.builder.HashCodeBuilder;
13 import org.apache.commons.lang3.builder.EqualsBuilder;
14 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
16 import javax.xml.bind.annotation.XmlRootElement;
17 import javax.xml.bind.annotation.XmlElement;
20 * @file TimeStamp.java
22 * @brief Class representing a TimeStamp
24 * A property describing a timestamp based following the rules of
25 * java.util.Date, also given the time stamp represent the time when
26 * something happened, then a name is attached to this property so
27 * to qualify what are we talking about
30 public class TimeStamp extends Property {
31 private static final long serialVersionUID = 1L;
33 private long timestamp;
35 private String timestampName;
37 public static final String TimeStampPropName = "timeStamp";
40 * Construct a TimeStamp proporty
42 * @param timestamp the time stampt we want to describe in "epoch"
43 * format following the rules of java.util.Date
44 * @param timestampName A qualifier for the timestamp, for example
45 * "JoinTime" or any even qualifier could come up
47 * @return Constructed object
49 public TimeStamp(long timestamp, String timestampName) {
50 super(TimeStampPropName);
51 this.timestamp = timestamp;
52 this.timestampName = timestampName;
56 * Private constructor used for JAXB mapping
59 super(TimeStampPropName);
61 this.timestampName = null;
64 public TimeStamp clone() {
65 return new TimeStamp(this.timestamp, this.timestampName);
68 public long getValue() {
69 return this.timestamp;
72 public String getTimeStampName() {
73 return this.timestampName;
77 public int hashCode() {
78 return HashCodeBuilder.reflectionHashCode(this);
82 public boolean equals(Object obj) {
83 return EqualsBuilder.reflectionEquals(this, obj);
87 public String toString() {
88 return "TimeStamp[" + ReflectionToStringBuilder.toString(this) + "]";