blob: 9211576bc45b42c75439db412367002f83050d0b [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 SHIMIZU34847b72016-06-07 14:31:54 -070061 public DiscreteResources remove(Set<DiscreteResource> removed) {
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070062 return this;
63 }
64
65 @Override
66 public Set<DiscreteResource> values() {
67 return ImmutableSet.of();
68 }
Sho SHIMIZU68e8bfa2016-06-08 12:01:31 -070069
70 @Override
71 public String toString() {
72 return MoreObjects.toStringHelper(this)
73 .add("values", ImmutableSet.of())
74 .toString();
75 }
Sho SHIMIZUf57d6002016-05-19 11:38:16 -070076}