blob: cd25a9262808d2c70a75d7633f82e1e3927d491c [file] [log] [blame]
Sho SHIMIZUf33b8932016-01-25 18:43:32 -08001/*
2 * Copyright 2016 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.net.newresource;
17
18import com.google.common.annotations.Beta;
19import com.google.common.collect.ImmutableList;
20
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * ResourceId for {@link ContinuousResource}
25 *
26 * Note: This class is exposed to the public, but intended to be used in the resource API
27 * implementation only. It is not for resource API user.
28 */
29@Beta
30// TODO: consider how to restrict the visibility
31public final class ContinuousResourceId extends ResourceId {
32 // for printing purpose only (used in toString() implementation)
33 private final String name;
34
35 ContinuousResourceId(ImmutableList<Object> components, String name) {
36 super(components);
37 this.name = checkNotNull(name);
38 }
39
40 @Override
41 public String toString() {
42 // due to performance consideration, the value might need to be stored in a field
43 return ImmutableList.builder()
44 .addAll(components.subList(0, components.size() - 1))
45 .add(name)
46 .build().toString();
47 }
48}