blob: 91edcdbd98dd1afaab803880305a7bb62f7d6f2c [file] [log] [blame]
Richard S. Halldfd78a42012-05-11 20:19:02 +00001/*
Carsten Ziegeler3314f912014-07-30 07:22:32 +00002 * Copyright (c) OSGi Alliance (2011, 2013). All Rights Reserved.
Richard S. Halldfd78a42012-05-11 20:19:02 +00003 *
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
17package org.osgi.resource;
18
19import java.util.List;
Carsten Ziegeler3314f912014-07-30 07:22:32 +000020import org.osgi.annotation.versioning.ConsumerType;
Richard S. Halldfd78a42012-05-11 20:19:02 +000021
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 Ziegeler3314f912014-07-30 07:22:32 +000033 * @author $Id: c7b6462fb53b38ac3071d7ba73af9dad2af6b9ce $
Richard S. Halldfd78a42012-05-11 20:19:02 +000034 */
Carsten Ziegeler3314f912014-07-30 07:22:32 +000035@ConsumerType
Richard S. Halldfd78a42012-05-11 20:19:02 +000036public 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}