Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 10 | package com.intel.jndn.utils; |
| 11 | |
| 12 | /** |
| 13 | * |
| 14 | * @author Andrew Brown <andrew.brown@intel.com> |
| 15 | */ |
| 16 | public class ClientObservableEvent<T> { |
| 17 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 18 | boolean success; |
| 19 | long timestamp; |
| 20 | T packet; |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 21 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 22 | public ClientObservableEvent(T packet) { |
| 23 | fromPacket(packet); |
| 24 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 25 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 26 | public ClientObservableEvent() { |
| 27 | timestamp = System.currentTimeMillis(); |
| 28 | success = false; |
| 29 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 30 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 31 | public final void fromPacket(T packet_) { |
| 32 | timestamp = System.currentTimeMillis(); |
| 33 | success = !Exception.class.isInstance(packet_); |
| 34 | packet = packet_; |
| 35 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 36 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 37 | public boolean isSuccess() { |
| 38 | return success; |
| 39 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 40 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 41 | public void setSuccess(boolean success) { |
| 42 | this.success = success; |
| 43 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 44 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 45 | public long getTimestamp() { |
| 46 | return timestamp; |
| 47 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 48 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 49 | public void setTimestamp(long timestamp) { |
| 50 | this.timestamp = timestamp; |
| 51 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 52 | |
Andrew Brown | 7b1daf3 | 2015-01-19 16:36:01 -0800 | [diff] [blame] | 53 | public T getPacket() { |
| 54 | return packet; |
| 55 | } |
| 56 | |
| 57 | public void setPacket(T packet) { |
| 58 | this.packet = packet; |
| 59 | } |
Andrew Brown | 3f2521a | 2015-01-17 22:10:15 -0800 | [diff] [blame] | 60 | |
| 61 | } |