blob: 66997874d715ecadc5cab9235c0c47832d940425 [file] [log] [blame]
Sho SHIMIZUf57d6002016-05-19 11:38:16 -07001/*
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 */
16package org.onosproject.store.resource.impl;
17
18import com.google.common.collect.ImmutableSet;
19import org.onosproject.net.resource.DiscreteResource;
20import org.onosproject.net.resource.DiscreteResourceId;
21
22import java.util.List;
23import java.util.Optional;
24import java.util.Set;
25
26/**
27 * Represents an empty set of discrete resource.
28 */
29final 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}