blob: 87da8836381cdba51dc118c22e22ce20186d885c [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
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070022import java.util.Optional;
23import java.util.Set;
24
25/**
26 * Represents an empty set of discrete resource.
27 */
28final class EmptyDiscreteResources implements DiscreteResources {
29 static final DiscreteResources INSTANCE = new EmptyDiscreteResources();
30
31 // for serializer
32 private EmptyDiscreteResources() {}
33
34 @Override
35 public Optional<DiscreteResource> lookup(DiscreteResourceId id) {
36 return Optional.empty();
37 }
38
39 @Override
40 public DiscreteResources difference(DiscreteResources other) {
41 return this;
42 }
43
44 @Override
45 public boolean isEmpty() {
46 return true;
47 }
48
49 @Override
Sho SHIMIZU34847b72016-06-07 14:31:54 -070050 public boolean containsAny(Set<DiscreteResource> other) {
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070051 return false;
52 }
53
54 @Override
55 public DiscreteResources add(DiscreteResources other) {
56 return other;
57 }
58
59 @Override
Sho SHIMIZU34847b72016-06-07 14:31:54 -070060 public DiscreteResources remove(Set<DiscreteResource> removed) {
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070061 return this;
62 }
63
64 @Override
65 public Set<DiscreteResource> values() {
66 return ImmutableSet.of();
67 }
68}