1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension

File ExtensionDependency.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

4
7
2
1
112
30
4
0.57
3.5
2
2

Classes

Class Line # Actions
ExtensionDependency 34 7 0% 4 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension;
21   
22    import java.util.Collection;
23    import java.util.Map;
24   
25    import org.xwiki.extension.repository.ExtensionRepositoryDescriptor;
26    import org.xwiki.extension.version.VersionConstraint;
27   
28    /**
29    * An extension dependency.
30    *
31    * @version $Id: eff8f02ca5b489c20744ca5582d8aa2a428b6868 $
32    * @since 4.0M1
33    */
 
34    public interface ExtensionDependency
35    {
36    /**
37    * @return the id (or feature) of the target extension
38    */
39    String getId();
40   
41    /**
42    * @return the version constraint of the target extension
43    */
44    VersionConstraint getVersionConstraint();
45   
46    /**
47    * @return the custom repositories provided by the extension (usually to resolve dependencies)
48    * @since 7.3M1
49    */
50    Collection<ExtensionRepositoryDescriptor> getRepositories();
51   
52    /**
53    * Extends {@link ExtensionDependency} standard properties.
54    * <p>
55    * Theses are generally provided by specific repositories. For example a AETHER repository will provide AETHER
56    * Dependency representation to avoid conversion when searching for the dependency on a AETHER based repository.
57    *
58    * @return the properties
59    */
60    Map<String, Object> getProperties();
61   
62    /**
63    * @param key the property key
64    * @return the property value
65    */
66    Object getProperty(String key);
67   
68    /**
69    * Get a property.
70    *
71    * @param <T> type of the property value
72    * @param key the property key
73    * @param def the value to return if no property is associated to the provided key
74    * @return the property value or <code>default</code> of the property is not found
75    * @see #getProperty(String)
76    */
77    <T> T getProperty(String key, T def);
78   
79    /**
80    * Indicate if the passed extension is compatible with this dependency.
81    *
82    * @param extension the extension to check
83    * @return true if the passed extension is compatible, false otherwise
84    * @since 8.1M1
85    */
 
86  0 toggle default boolean isCompatible(Extension extension)
87    {
88  0 if (isCompatible(extension.getId())) {
89  0 return true;
90    }
91   
92  0 for (ExtensionId extensionId : extension.getExtensionFeatures()) {
93  0 if (isCompatible(extensionId)) {
94  0 return true;
95    }
96    }
97   
98  0 return false;
99    }
100   
101    /**
102    * Indicate if the passed extension id is compatible with this dependency.
103    *
104    * @param extensionId the extension to check
105    * @return true if the passed extension id is compatible, false otherwise
106    * @since 8.1M1
107    */
 
108  0 toggle default boolean isCompatible(ExtensionId extensionId)
109    {
110  0 return getId().equals(extensionId.getId()) && getVersionConstraint().isCompatible(extensionId.getVersion());
111    }
112    }