Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d894e80734f78bb0de010a89e8d1713478f5af58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/******************************************************************************* 
* Copyright (c) 2009, 2012 IBM and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*   IBM - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.p2.metadata;

import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;

/**
 * A requirement represents some external constraint on an {@link IInstallableUnit}.
 * Each requirement represents something an {@link IInstallableUnit} needs that
 * it expects to be provided by another {@link IInstallableUnit}. Requirements are
 * entirely generic, and are intended to be capable of representing anything that
 * an {@link IInstallableUnit} may need either at install time, or at runtime.
 * <p>
 * Instances of this class are handle objects and do not necessarily
 * reflect entities that exist in any particular profile or repository. These handle 
 * objects can be created using {@link MetadataFactory}.
 * </p>
 * 
 * @noimplement This interface is not intended to be implemented by clients.
 * @noextend This interface is not intended to be extended by clients.
 * @since 2.0
 * @see IProvidedCapability
 * @see MetadataFactory#createRequirement(String, String, VersionRange, String, boolean, boolean, boolean)
 */
public interface IRequirement {

	/**
	 * Returns the minimum cardinality of the requirement. That is, the minimum
	 * number of capabilities that must be provided that match this requirement before
	 * this requirement is considered fully satisfied.  A minimum cardinality of 0 indicates 
	 * that the requirement is optional.
	 * 
	 * @return the minimum cardinality of this requirement
	 */
	int getMin();

	/**
	 * Returns the maximum cardinality of the requirement. That is, the maximum
	 * number of capabilities that are permitted to be present that satisfy this requirement.
	 * A maximum cardinality of 0 indicates that there must <em>not</em> be
	 * any installable unit in the system that satisfies this requirement.
	 * 
	 * @return the maximum cardinality of this requirement
	 */
	int getMax();

	/**
	 * @noreference This method is not intended to be referenced by clients.
	 */
	IMatchExpression<IInstallableUnit> getFilter();

	/**
	 * Returns a boolean match expression that will return true for any
	 * {@link IInstallableUnit} that matches the requirement.
	 * @return A boolean match expression for installable unit matching.
	 */
	IMatchExpression<IInstallableUnit> getMatches();

	/**
	 * Returns whether the provided capabilities of the given installable unit satisfy
	 * this requirement.
	 * 
	 * @param iu the installable unit to check for matching capabilities
	 * @return <code>true</code> if the given installable unit satisfies this
	 * requirement, and <code>false</code> otherwise.
	 */
	boolean isMatch(IInstallableUnit iu);

	/**
	 * Returns whether this requirement should cause extra installable units
	 * to be installed in order to satisfy it. 
	 * @return <code>true</code> if additional installable units should be installed
	 * to satisfy this requirement, and <code>false</code> otherwise
	 */
	boolean isGreedy();

	/**
	 * Returns a textual description of this requirement.
	 * 
	 * @return a textual description of this requirement
	 */
	String getDescription();

}

Back to the top