blob: 1d92436661eef37e4dbadcd37479ba60f4b468e8 [file] [log] [blame]
Sho SHIMIZU76b30f72016-01-11 14:08:35 -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;
Sho SHIMIZU2486ddd2016-01-29 11:51:12 -080019import com.google.common.collect.ImmutableList;
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080020
Sho SHIMIZU7dac8a42016-01-27 12:04:39 -080021import java.util.Optional;
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080022
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080023/**
24 * Represents identifier of resource.
25 * This class is exposed to public, but intended to use only in ResourceStore implementations.
26 */
27@Beta
Sho SHIMIZU2d310222016-01-22 11:45:11 -080028public abstract class ResourceId {
Sho SHIMIZU2a704512016-01-26 14:41:34 -080029 static final DiscreteResourceId ROOT = new DiscreteResourceId();
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080030
Sho SHIMIZU2486ddd2016-01-29 11:51:12 -080031 abstract ImmutableList<Object> components();
32
Sho SHIMIZU7dac8a42016-01-27 12:04:39 -080033 /**
34 * Returns the parent resource ID of this instance.
35 *
Sho SHIMIZU19816f42016-01-29 11:32:02 -080036 * @return the parent resource ID of this instance.
Sho SHIMIZU7dac8a42016-01-27 12:04:39 -080037 * If there is no parent, empty instance will be returned.
38 */
39 public abstract Optional<DiscreteResourceId> parent();
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080040
Sho SHIMIZU2d310222016-01-22 11:45:11 -080041 /**
42 * Returns a resource ID of a child of this resource based on the specified object.
Sho SHIMIZU2a704512016-01-26 14:41:34 -080043 * If the given object is a {@link Class} instance, {@link IllegalArgumentException} is thrown.
Sho SHIMIZU2d310222016-01-22 11:45:11 -080044 *
45 * @param child the last component of the child
46 * @return a child resource ID
47 */
Sho SHIMIZU2a704512016-01-26 14:41:34 -080048 public abstract DiscreteResourceId child(Object child);
Sho SHIMIZU2d310222016-01-22 11:45:11 -080049
Sho SHIMIZU2a704512016-01-26 14:41:34 -080050 /**
51 * Returns a resource ID of a child of this resource based on the specified object.
52 *
53 * @param child the last component of the child
54 * @return a child resource ID
55 */
56 public abstract ContinuousResourceId child(Class<?> child);
Sho SHIMIZU76b30f72016-01-11 14:08:35 -080057}