Committed by
Gerrit Code Review
Check preconditions when registering/unregistering resources
Change-Id: Ibe7897fcdef791fb83eb6521c5e48e795612f8f5
Showing
1 changed file
with
9 additions
and
0 deletions
... | @@ -35,6 +35,7 @@ import java.util.List; | ... | @@ -35,6 +35,7 @@ import java.util.List; |
35 | import java.util.Optional; | 35 | import java.util.Optional; |
36 | import java.util.stream.Collectors; | 36 | import java.util.stream.Collectors; |
37 | 37 | ||
38 | +import static com.google.common.base.Preconditions.checkArgument; | ||
38 | import static com.google.common.base.Preconditions.checkNotNull; | 39 | import static com.google.common.base.Preconditions.checkNotNull; |
39 | 40 | ||
40 | /** | 41 | /** |
... | @@ -127,12 +128,20 @@ public final class ResourceManager implements ResourceService, ResourceAdminServ | ... | @@ -127,12 +128,20 @@ public final class ResourceManager implements ResourceService, ResourceAdminServ |
127 | 128 | ||
128 | @Override | 129 | @Override |
129 | public <T> boolean registerResources(ResourcePath parent, List<T> children) { | 130 | public <T> boolean registerResources(ResourcePath parent, List<T> children) { |
131 | + checkNotNull(parent); | ||
132 | + checkNotNull(children); | ||
133 | + checkArgument(!children.isEmpty()); | ||
134 | + | ||
130 | List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x)); | 135 | List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x)); |
131 | return store.register(parent, resources); | 136 | return store.register(parent, resources); |
132 | } | 137 | } |
133 | 138 | ||
134 | @Override | 139 | @Override |
135 | public <T> boolean unregisterResources(ResourcePath parent, List<T> children) { | 140 | public <T> boolean unregisterResources(ResourcePath parent, List<T> children) { |
141 | + checkNotNull(parent); | ||
142 | + checkNotNull(children); | ||
143 | + checkArgument(!children.isEmpty()); | ||
144 | + | ||
136 | List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x)); | 145 | List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x)); |
137 | return store.unregister(parent, resources); | 146 | return store.unregister(parent, resources); |
138 | } | 147 | } | ... | ... |
-
Please register or login to post a comment