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.List; |
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 resource is the representation of a uniquely identified and typed data. A |
| 24 | * resource declares requirements that need to be satisfied by capabilities |
| 25 | * before it can provide its capabilities. |
| 26 | * |
| 27 | * <p> |
| 28 | * Instances of this type must be <i>effectively immutable</i>. That is, for a |
| 29 | * given instance of this interface, the methods defined by this interface must |
| 30 | * always return the same result. |
| 31 | * |
| 32 | * @ThreadSafe |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 33 | * @author $Id: c7b6462fb53b38ac3071d7ba73af9dad2af6b9ce $ |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 34 | */ |
Carsten Ziegeler | 3314f91 | 2014-07-30 07:22:32 +0000 | [diff] [blame^] | 35 | @ConsumerType |
Richard S. Hall | dfd78a4 | 2012-05-11 20:19:02 +0000 | [diff] [blame] | 36 | public interface Resource { |
| 37 | /** |
| 38 | * Returns the capabilities declared by this resource. |
| 39 | * |
| 40 | * @param namespace The namespace of the declared capabilities to return or |
| 41 | * {@code null} to return the declared capabilities from all |
| 42 | * namespaces. |
| 43 | * @return An unmodifiable list containing the declared {@link Capability}s |
| 44 | * from the specified namespace. The returned list will be empty if |
| 45 | * this resource declares no capabilities in the specified |
| 46 | * namespace. |
| 47 | */ |
| 48 | List<Capability> getCapabilities(String namespace); |
| 49 | |
| 50 | /** |
| 51 | * Returns the requirements declared by this bundle resource. |
| 52 | * |
| 53 | * @param namespace The namespace of the declared requirements to return or |
| 54 | * {@code null} to return the declared requirements from all |
| 55 | * namespaces. |
| 56 | * @return An unmodifiable list containing the declared {@link Requirement} |
| 57 | * s from the specified namespace. The returned list will be empty |
| 58 | * if this resource declares no requirements in the specified |
| 59 | * namespace. |
| 60 | */ |
| 61 | List<Requirement> getRequirements(String namespace); |
| 62 | |
| 63 | /** |
| 64 | * Compares this {@code Resource} to another {@code Resource}. |
| 65 | * |
| 66 | * <p> |
| 67 | * This {@code Resource} is equal to another {@code Resource} if both have |
| 68 | * the same content and come from the same location. Location may be defined |
| 69 | * as the bundle location if the resource is an installed bundle or the |
| 70 | * repository location if the resource is in a repository. |
| 71 | * |
| 72 | * @param obj The object to compare against this {@code Resource}. |
| 73 | * @return {@code true} if this {@code Resource} is equal to the other |
| 74 | * object; {@code false} otherwise. |
| 75 | */ |
| 76 | boolean equals(Object obj); |
| 77 | |
| 78 | /** |
| 79 | * Returns the hashCode of this {@code Resource}. |
| 80 | * |
| 81 | * @return The hashCode of this {@code Resource}. |
| 82 | */ |
| 83 | int hashCode(); |
| 84 | } |