View Javadoc
1   /*-
2    * #%L
3    * io.earcam.instrumental.archive.osgi
4    * %%
5    * Copyright (C) 2018 earcam
6    * %%
7    * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT)
8    * 
9    * You <b>must</b> choose to accept, in full - any individual or combination of 
10   * the following licenses:
11   * <ul>
12   * 	<li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li>
13   * 	<li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li>
14   * 	<li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li>
15   * 	<li><a href="https://opensource.org/licenses/MIT">MIT</a></li>
16   * </ul>
17   * #L%
18   */
19  package io.earcam.instrumental.archive.osgi;
20  
21  import static io.earcam.instrumental.module.osgi.ClauseParameters.EMPTY_PARAMETERS;
22  
23  import java.util.Arrays;
24  import java.util.List;
25  import java.util.function.Predicate;
26  
27  import io.earcam.instrumental.archive.AsJarBuilder;
28  import io.earcam.instrumental.fluent.Fluent;
29  import io.earcam.instrumental.module.osgi.ClauseParameters;
30  
31  /**
32   * <p>
33   * AsOsgiBundle class.
34   * </p>
35   *
36   */
37  public interface AsOsgiBundle extends AsJarBuilder<AsOsgiBundle> {
38  
39  	/**
40  	 * <p>
41  	 * asOsgiBundle.
42  	 * </p>
43  	 *
44  	 * @return a {@link io.earcam.instrumental.archive.osgi.AsOsgiBundle} object.
45  	 */
46  	@Fluent
47  	public static AsOsgiBundle asOsgiBundle()
48  	{
49  		return new DefaultAsOsgiBundle();
50  	}
51  
52  
53  	public default AsOsgiBundle named(String symbolicName)
54  	{
55  		return named(symbolicName, EMPTY_PARAMETERS);
56  	}
57  
58  
59  	public abstract AsOsgiBundle named(String symbolicName, ClauseParameters parameters);
60  
61  
62  	public abstract AsOsgiBundle withActivator(Class<?> activator);
63  
64  
65  	public abstract AsOsgiBundle withActivator(String canonicalName);
66  
67  
68  	/**
69  	 * <p>
70  	 * <code>Export-Package</code> using a predicate string matching.
71  	 * </p>
72  	 * <p>
73  	 * The matchers are applied in order - after the first successful match,
74  	 * no other matchers are tested.
75  	 * </p>
76  	 *
77  	 * @param exportMatcher a {@link java.util.function.Predicate} object.
78  	 * @param parameters a {@link io.earcam.instrumental.module.osgi.ClauseParameters} object.
79  	 * @return a {@link io.earcam.instrumental.archive.osgi.DefaultAsOsgiBundle} object.
80  	 */
81  	public abstract AsOsgiBundle exporting(Predicate<String> exportMatcher, ClauseParameters parameters);
82  
83  
84  	/**
85  	 * <p>
86  	 * <code>Export-Package</code> without attributes or directives
87  	 * </p>
88  	 * 
89  	 * @param type
90  	 * @return
91  	 */
92  	public default AsOsgiBundle exporting(Class<?> type)
93  	{
94  		return exporting(type, EMPTY_PARAMETERS);
95  	}
96  
97  
98  	public abstract AsOsgiBundle exporting(Class<?> type, ClauseParameters parameters);
99  
100 
101 	public default AsOsgiBundle exporting(Package paquet, ClauseParameters parameters)
102 	{
103 		return exporting(paquet.getName(), parameters);
104 	}
105 
106 
107 	public abstract AsOsgiBundle exporting(String paquet, ClauseParameters parameters);
108 
109 
110 	public default AsOsgiBundle importing(String paquet)
111 	{
112 		return importing(paquet, EMPTY_PARAMETERS);
113 	}
114 
115 
116 	public abstract AsOsgiBundle importing(String paquet, ClauseParameters parameters);
117 
118 
119 	public abstract AsOsgiBundle autoImporting();
120 
121 
122 	public default AsOsgiBundle autoImporting(PackageBundleMapper... mappers)
123 	{
124 		return autoImporting(Arrays.asList(mappers));
125 	}
126 
127 
128 	public abstract AsOsgiBundle autoImporting(List<PackageBundleMapper> mappers);
129 }