Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 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 | */ |
Sho SHIMIZU | e18cb12 | 2016-02-22 21:04:56 -0800 | [diff] [blame] | 16 | package org.onosproject.net.resource; |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.annotations.Beta; |
Sho SHIMIZU | 2486ddd | 2016-01-29 11:51:12 -0800 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableList; |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 20 | |
Sho SHIMIZU | 7dac8a4 | 2016-01-27 12:04:39 -0800 | [diff] [blame] | 21 | import java.util.Optional; |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 22 | |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 23 | /** |
| 24 | * Represents identifier of resource. |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 25 | */ |
| 26 | @Beta |
Sho SHIMIZU | 2d31022 | 2016-01-22 11:45:11 -0800 | [diff] [blame] | 27 | public abstract class ResourceId { |
Sho SHIMIZU | 2a70451 | 2016-01-26 14:41:34 -0800 | [diff] [blame] | 28 | static final DiscreteResourceId ROOT = new DiscreteResourceId(); |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 29 | |
Sho SHIMIZU | 2486ddd | 2016-01-29 11:51:12 -0800 | [diff] [blame] | 30 | abstract ImmutableList<Object> components(); |
| 31 | |
Sho SHIMIZU | 74ac901 | 2016-02-12 10:03:21 -0800 | [diff] [blame] | 32 | abstract String simpleTypeName(); |
| 33 | |
Sho SHIMIZU | caa2f7b | 2016-02-12 17:38:49 -0800 | [diff] [blame] | 34 | // caller must pass a non-null value |
| 35 | abstract boolean isTypeOf(Class<?> type); |
| 36 | |
| 37 | // caller must pass a non-null value |
| 38 | abstract boolean isSubTypeOf(Class<?> ancestor); |
| 39 | |
Sho SHIMIZU | 7dac8a4 | 2016-01-27 12:04:39 -0800 | [diff] [blame] | 40 | /** |
| 41 | * Returns the parent resource ID of this instance. |
| 42 | * |
Sho SHIMIZU | 19816f4 | 2016-01-29 11:32:02 -0800 | [diff] [blame] | 43 | * @return the parent resource ID of this instance. |
Sho SHIMIZU | 7dac8a4 | 2016-01-27 12:04:39 -0800 | [diff] [blame] | 44 | * If there is no parent, empty instance will be returned. |
| 45 | */ |
| 46 | public abstract Optional<DiscreteResourceId> parent(); |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 47 | |
Sho SHIMIZU | 2d31022 | 2016-01-22 11:45:11 -0800 | [diff] [blame] | 48 | /** |
| 49 | * Returns a resource ID of a child of this resource based on the specified object. |
Sho SHIMIZU | 2a70451 | 2016-01-26 14:41:34 -0800 | [diff] [blame] | 50 | * If the given object is a {@link Class} instance, {@link IllegalArgumentException} is thrown. |
Sho SHIMIZU | 2d31022 | 2016-01-22 11:45:11 -0800 | [diff] [blame] | 51 | * |
| 52 | * @param child the last component of the child |
| 53 | * @return a child resource ID |
| 54 | */ |
Sho SHIMIZU | 2a70451 | 2016-01-26 14:41:34 -0800 | [diff] [blame] | 55 | public abstract DiscreteResourceId child(Object child); |
Sho SHIMIZU | 2d31022 | 2016-01-22 11:45:11 -0800 | [diff] [blame] | 56 | |
Sho SHIMIZU | 2a70451 | 2016-01-26 14:41:34 -0800 | [diff] [blame] | 57 | /** |
| 58 | * Returns a resource ID of a child of this resource based on the specified object. |
| 59 | * |
| 60 | * @param child the last component of the child |
| 61 | * @return a child resource ID |
| 62 | */ |
| 63 | public abstract ContinuousResourceId child(Class<?> child); |
Sho SHIMIZU | 76b30f7 | 2016-01-11 14:08:35 -0800 | [diff] [blame] | 64 | } |