blob: af2a61443a6cac817719215bf74769e8d94aa5f4 [file] [log] [blame]
Andrew Brown3f2521a2015-01-17 22:10:15 -08001/*
2 * File name: ClientObservableEvent.java
3 *
4 * Purpose:
5 *
6 * © Copyright Intel Corporation. All rights reserved.
7 * Intel Corporation, 2200 Mission College Boulevard,
8 * Santa Clara, CA 95052-8119, USA
9 */
10package com.intel.jndn.utils;
11
12/**
13 *
14 * @author Andrew Brown <andrew.brown@intel.com>
15 */
16public class ClientObservableEvent<T> {
17
Andrew Brown7b1daf32015-01-19 16:36:01 -080018 boolean success;
19 long timestamp;
20 T packet;
Andrew Brown3f2521a2015-01-17 22:10:15 -080021
Andrew Brown7b1daf32015-01-19 16:36:01 -080022 public ClientObservableEvent(T packet) {
23 fromPacket(packet);
24 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080025
Andrew Brown7b1daf32015-01-19 16:36:01 -080026 public ClientObservableEvent() {
27 timestamp = System.currentTimeMillis();
28 success = false;
29 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080030
Andrew Brown7b1daf32015-01-19 16:36:01 -080031 public final void fromPacket(T packet_) {
32 timestamp = System.currentTimeMillis();
33 success = !Exception.class.isInstance(packet_);
34 packet = packet_;
35 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080036
Andrew Brown7b1daf32015-01-19 16:36:01 -080037 public boolean isSuccess() {
38 return success;
39 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080040
Andrew Brown7b1daf32015-01-19 16:36:01 -080041 public void setSuccess(boolean success) {
42 this.success = success;
43 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080044
Andrew Brown7b1daf32015-01-19 16:36:01 -080045 public long getTimestamp() {
46 return timestamp;
47 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080048
Andrew Brown7b1daf32015-01-19 16:36:01 -080049 public void setTimestamp(long timestamp) {
50 this.timestamp = timestamp;
51 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080052
Andrew Brown7b1daf32015-01-19 16:36:01 -080053 public T getPacket() {
54 return packet;
55 }
56
57 public void setPacket(T packet) {
58 this.packet = packet;
59 }
Andrew Brown3f2521a2015-01-17 22:10:15 -080060
61}