Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 1 | /* |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 2 | * Copyright (c) OSGi Alliance (2011, 2013). All Rights Reserved. |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [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 | */ |
| 16 | |
| 17 | package org.osgi.resource; |
| 18 | |
| 19 | import java.util.Map; |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 20 | import org.osgi.annotation.versioning.ConsumerType; |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * A capability that has been declared from a {@link Resource}. |
| 24 | * |
| 25 | * <p> |
| 26 | * Instances of this type must be <i>effectively immutable</i>. That is, for a |
| 27 | * given instance of this interface, the methods defined by this interface must |
| 28 | * always return the same result. |
| 29 | * |
| 30 | * @ThreadSafe |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 31 | * @author $Id: e79d11402e14e170443c8a2a9da835391cd1ccc8 $ |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 32 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 33 | @ConsumerType |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 34 | public interface Capability { |
| 35 | |
| 36 | /** |
| 37 | * Returns the namespace of this capability. |
| 38 | * |
| 39 | * @return The namespace of this capability. |
| 40 | */ |
| 41 | String getNamespace(); |
| 42 | |
| 43 | /** |
| 44 | * Returns the directives of this capability. |
| 45 | * |
| 46 | * @return An unmodifiable map of directive names to directive values for |
| 47 | * this capability, or an empty map if this capability has no |
| 48 | * directives. |
| 49 | */ |
| 50 | Map<String, String> getDirectives(); |
| 51 | |
| 52 | /** |
| 53 | * Returns the attributes of this capability. |
| 54 | * |
| 55 | * @return An unmodifiable map of attribute names to attribute values for |
| 56 | * this capability, or an empty map if this capability has no |
| 57 | * attributes. |
| 58 | */ |
| 59 | Map<String, Object> getAttributes(); |
| 60 | |
| 61 | /** |
| 62 | * Returns the resource declaring this capability. |
| 63 | * |
| 64 | * @return The resource declaring this capability. |
| 65 | */ |
| 66 | Resource getResource(); |
| 67 | |
| 68 | /** |
| 69 | * Compares this {@code Capability} to another {@code Capability}. |
| 70 | * |
| 71 | * <p> |
| 72 | * This {@code Capability} is equal to another {@code Capability} if they |
| 73 | * have the same namespace, directives and attributes and are declared by |
| 74 | * the same resource. |
| 75 | * |
| 76 | * @param obj The object to compare against this {@code Capability}. |
| 77 | * @return {@code true} if this {@code Capability} is equal to the other |
| 78 | * object; {@code false} otherwise. |
| 79 | */ |
| 80 | boolean equals(Object obj); |
| 81 | |
| 82 | /** |
| 83 | * Returns the hashCode of this {@code Capability}. |
| 84 | * |
| 85 | * @return The hashCode of this {@code Capability}. |
| 86 | */ |
| 87 | int hashCode(); |
| 88 | } |