1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.registry;
17
18 import org.fourthline.cling.model.ExpirationDetails;
19
20
21
22
23
24
25 class RegistryItem<K, I> {
26
27 private K key;
28 private I item;
29 private ExpirationDetails expirationDetails = new ExpirationDetails();
30
31 RegistryItem(K key) {
32 this.key = key;
33 }
34
35 RegistryItem(K key, I item, int maxAgeSeconds) {
36 this.key = key;
37 this.item = item;
38 this.expirationDetails = new ExpirationDetails(maxAgeSeconds);
39 }
40
41 public K getKey() {
42 return key;
43 }
44
45 public I getItem() {
46 return item;
47 }
48
49 public ExpirationDetails getExpirationDetails() {
50 return expirationDetails;
51 }
52
53 public boolean equals(Object o) {
54 if (this == o) return true;
55 if (o == null || getClass() != o.getClass()) return false;
56
57 RegistryItem that = (RegistryItem) o;
58
59 return key.equals(that.key);
60 }
61
62 public int hashCode() {
63 return key.hashCode();
64 }
65
66 @Override
67 public String toString() {
68 return "("+getClass().getSimpleName()+") " + getExpirationDetails() + " KEY: " + getKey() + " ITEM: " + getItem();
69 }
70 }