blob: 55a0e9499b3eff4e62570e0bae68fcc4847a3223 [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
Sho SHIMIZU68e8bfa2016-06-08 12:01:31 -070018import com.google.common.base.MoreObjects;
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070019import com.google.common.collect.ImmutableSet;
20import org.onosproject.net.resource.DiscreteResource;
21import org.onosproject.net.resource.DiscreteResourceId;
22
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070023import java.util.Optional;
24import java.util.Set;
25
26/**
27 * Represents an empty set of discrete resource.
28 */
29final class EmptyDiscreteResources implements DiscreteResources {
Sho SHIMIZU226d0412016-06-08 11:32:12 -070030 static final EmptyDiscreteResources INSTANCE = new EmptyDiscreteResources();
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070031
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
Sho SHIMIZU34847b72016-06-07 14:31:54 -070051 public boolean containsAny(Set<DiscreteResource> other) {
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070052 return false;
53 }
54
55 @Override
56 public DiscreteResources add(DiscreteResources other) {
57 return other;
58 }
59
60 @Override
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070061 public Set<DiscreteResource> values() {
62 return ImmutableSet.of();
63 }
Sho SHIMIZU68e8bfa2016-06-08 12:01:31 -070064
65 @Override
66 public String toString() {
67 return MoreObjects.toStringHelper(this)
68 .add("values", ImmutableSet.of())
69 .toString();
70 }
Sho SHIMIZU9cc4a242016-05-26 12:55:35 -070071
72 @Override
73 public <T> Set<DiscreteResource> valuesOf(Class<T> cls) {
74 return ImmutableSet.of();
75 }
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070076}