1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.api;
18
19 import com.google.common.base.Objects;
20
21 import javax.annotation.Nullable;
22 import java.util.Collection;
23
24
25
26
27
28
29
30 public class ExpandableProperty<T> {
31 private final int size;
32
33 public ExpandableProperty(int size) {
34 this.size = size;
35 items = null;
36 }
37
38 public ExpandableProperty(int size, @Nullable Collection<T> items) {
39 this.size = size;
40 this.items = items;
41 }
42
43 public ExpandableProperty(Collection<T> items) {
44 this.size = items.size();
45 this.items = items;
46 }
47
48 public int getSize() {
49 return size;
50 }
51
52 @Nullable
53 final private Collection<T> items;
54
55 @Nullable
56 public Iterable<T> getItems() {
57 return items;
58 }
59
60 @Override
61 public String toString() {
62 return Objects.toStringHelper(this).
63 add("size", size).
64 add("items", items).
65 toString();
66 }
67
68
69 @Override
70 public boolean equals(Object obj) {
71 if (obj instanceof ExpandableProperty) {
72 ExpandableProperty that = (ExpandableProperty) obj;
73 return Objects.equal(this.size, that.size)
74 && Objects.equal(this.items, that.items);
75 }
76 return false;
77 }
78
79 @Override
80 public int hashCode() {
81 return Objects.hashCode(size, items);
82 }
83 }