Committed by
Sho SHIMIZU
Add a DiscreteResources sub type representing an empty set
This is for ONOS-4281 Change-Id: Ic4b6e2f00555681bb2af39dc1cf764d325ae8744
Showing
1 changed file
with
69 additions
and
0 deletions
core/store/dist/src/main/java/org/onosproject/store/resource/impl/EmptyDiscreteResources.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.store.resource.impl; | ||
| 17 | + | ||
| 18 | +import com.google.common.collect.ImmutableSet; | ||
| 19 | +import org.onosproject.net.resource.DiscreteResource; | ||
| 20 | +import org.onosproject.net.resource.DiscreteResourceId; | ||
| 21 | + | ||
| 22 | +import java.util.List; | ||
| 23 | +import java.util.Optional; | ||
| 24 | +import java.util.Set; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Represents an empty set of discrete resource. | ||
| 28 | + */ | ||
| 29 | +final class EmptyDiscreteResources implements DiscreteResources { | ||
| 30 | + static final DiscreteResources INSTANCE = new EmptyDiscreteResources(); | ||
| 31 | + | ||
| 32 | + // for serializer | ||
| 33 | + private EmptyDiscreteResources() {} | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Optional<DiscreteResource> lookup(DiscreteResourceId id) { | ||
| 37 | + return Optional.empty(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public DiscreteResources difference(DiscreteResources other) { | ||
| 42 | + return this; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public boolean isEmpty() { | ||
| 47 | + return true; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public boolean containsAny(List<DiscreteResource> other) { | ||
| 52 | + return false; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public DiscreteResources add(DiscreteResources other) { | ||
| 57 | + return other; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public DiscreteResources remove(List<DiscreteResource> removed) { | ||
| 62 | + return this; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public Set<DiscreteResource> values() { | ||
| 67 | + return ImmutableSet.of(); | ||
| 68 | + } | ||
| 69 | +} |
-
Please register or login to post a comment