Sho SHIMIZU

Write Javadoc for DiscreteResources

Change-Id: I94442852d889b91801ae334171f6a97b94a0954a
...@@ -22,24 +22,73 @@ import java.util.List; ...@@ -22,24 +22,73 @@ import java.util.List;
22 import java.util.Optional; 22 import java.util.Optional;
23 import java.util.Set; 23 import java.util.Set;
24 24
25 +/**
26 + * A common API for a set of discrete resources.
27 + */
25 interface DiscreteResources { 28 interface DiscreteResources {
29 + /**
30 + * Returns an instance representing an empty set.
31 + *
32 + * @return a empty set.
33 + */
26 static DiscreteResources empty() { 34 static DiscreteResources empty() {
27 return NonEncodableDiscreteResources.empty(); 35 return NonEncodableDiscreteResources.empty();
28 } 36 }
29 37
38 + /**
39 + * Look up a discrete resource instance by ID.
40 + *
41 + * @param id id
42 + * @return found instance enclosed by Optional
43 + */
30 Optional<DiscreteResource> lookup(DiscreteResourceId id); 44 Optional<DiscreteResource> lookup(DiscreteResourceId id);
31 45
46 + /**
47 + * Returns a difference set of this instance and the given instance.
48 + *
49 + * @param other other instance
50 + * @return a new DiscreteResources instance representing a difference set
51 + */
32 DiscreteResources difference(DiscreteResources other); 52 DiscreteResources difference(DiscreteResources other);
33 53
54 + /**
55 + * Checks that this instance is empty.
56 + *
57 + * @return true if this instance is empty, otherwise false.
58 + */
34 boolean isEmpty(); 59 boolean isEmpty();
35 60
61 + /**
62 + * Checks that this instance contains any of the given resources.
63 + *
64 + * @param other resources
65 + * @return true this instance contains a resource included in the given resources,
66 + * otherwise false.
67 + */
36 boolean containsAny(List<DiscreteResource> other); 68 boolean containsAny(List<DiscreteResource> other);
37 69
38 - // returns a new instance, not mutate the current instance 70 + /**
71 + * Returns a union set of this instance and the given instance.
72 + * Note: This method returns a new instance, not mutate the current instance
73 + *
74 + * @param other other instance
75 + * @return a new DiscreteResources instance representing a union set
76 + */
39 DiscreteResources add(DiscreteResources other); 77 DiscreteResources add(DiscreteResources other);
40 78
41 - // returns a new instance, not mutate the current instance 79 + /**
80 + * Returns a difference set of this instance and the given resources.
81 + * Note: This method returns a new instance, not mutate the current intance.
82 + *
83 + * @param removed resources
84 + * @return a new DiscreteResources instance representing a difference set
85 + */
42 DiscreteResources remove(List<DiscreteResource> removed); 86 DiscreteResources remove(List<DiscreteResource> removed);
43 87
88 + /**
89 + * Returns all of resources this instance holds.
90 + *
91 + * @return all resources
92 + */
44 Set<DiscreteResource> values(); 93 Set<DiscreteResource> values();
45 } 94 }
......