Package org.apache.ivy.plugins.version
Class ChainVersionMatcher
- java.lang.Object
-
- org.apache.ivy.plugins.version.AbstractVersionMatcher
-
- org.apache.ivy.plugins.version.ChainVersionMatcher
-
- All Implemented Interfaces:
IvySettingsAware,VersionMatcher
public class ChainVersionMatcher extends AbstractVersionMatcher
An implementation ofVersionMatcherchaining several version matchers, and implementing theVersionMatcherinterface by returning results from the first matcher in the chain accepting the version.
-
-
Constructor Summary
Constructors Constructor Description ChainVersionMatcher()Unique Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD)Indicates if this version matcher considers that the module found matches the asked one.booleanaccept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)Indicates if this version matcher considers that the module revision found matches the asked one.voidadd(VersionMatcher matcher)Adds aVersionMatcherto the chain.intcompare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, java.util.Comparator<ModuleRevisionId> staticComparator)This method should be overridden in most cases, because it uses the default contract to return 1 when it's not possible to know which revision is greater.java.util.List<VersionMatcher>getMatchers()Returns the list of matchers in the chain.booleanisDynamic(ModuleRevisionId askedMrid)Indicates if the given asked ModuleRevisionId should be considered as dynamic for the current VersionMatcher or not.booleanneedModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)Indicates if this VersionMatcher needs module descriptors to determine if a module revision matches the asked one.voidsetSettings(IvySettings settings)Sets the settings this matcher will use, and set to the matcher in the chain which implementsIvySettingsAware.-
Methods inherited from class org.apache.ivy.plugins.version.AbstractVersionMatcher
getName, getSettings, setName, toString
-
-
-
-
Method Detail
-
add
public void add(VersionMatcher matcher)
Adds aVersionMatcherto the chain.- Parameters:
matcher- the version matcher to add. Must not be null
-
setSettings
public void setSettings(IvySettings settings)
Sets the settings this matcher will use, and set to the matcher in the chain which implementsIvySettingsAware.- Specified by:
setSettingsin interfaceIvySettingsAware- Overrides:
setSettingsin classAbstractVersionMatcher- Parameters:
settings- the settings to use in the whole chain. Must not be null.
-
getMatchers
public java.util.List<VersionMatcher> getMatchers()
Returns the list of matchers in the chain.The list is returned as an unmodifiable view on the actual list of matchers, and will thus reflect further changes made in the chain.
- Returns:
- the list of matchers in the chain. Is never null.
-
isDynamic
public boolean isDynamic(ModuleRevisionId askedMrid)
Description copied from interface:VersionMatcherIndicates if the given asked ModuleRevisionId should be considered as dynamic for the current VersionMatcher or not.- Parameters:
askedMrid- the dependency module revision id as asked by a module- Returns:
- true if this revision is considered as a dynamic one, false otherwise
-
compare
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, java.util.Comparator<ModuleRevisionId> staticComparator)
Description copied from class:AbstractVersionMatcherThis method should be overridden in most cases, because it uses the default contract to return 1 when it's not possible to know which revision is greater.- Specified by:
comparein interfaceVersionMatcher- Overrides:
comparein classAbstractVersionMatcher- Parameters:
askedMrid- ModuleRevisionIdfoundMrid- ModuleRevisionIdstaticComparator- Comparator- Returns:
- int
-
accept
public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)
Description copied from interface:VersionMatcherIndicates if this version matcher considers that the module revision found matches the asked one.- Parameters:
askedMrid- ModuleRevisionIdfoundMrid- ModuleRevisionId- Returns:
- boolean
-
needModuleDescriptor
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)
Description copied from interface:VersionMatcherIndicates if this VersionMatcher needs module descriptors to determine if a module revision matches the asked one. Note that returning true in this method may imply big performance issues.- Specified by:
needModuleDescriptorin interfaceVersionMatcher- Overrides:
needModuleDescriptorin classAbstractVersionMatcher- Parameters:
askedMrid- ModuleRevisionIdfoundMrid- ModuleRevisionId- Returns:
- boolean
-
accept
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD)
Description copied from interface:VersionMatcherIndicates if this version matcher considers that the module found matches the asked one. This method can be called even needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) returns false, so it is required to implement it in any case, a usual default implementation being: return accept(askedMrid, foundMD.getResolvedModuleRevisionId());- Specified by:
acceptin interfaceVersionMatcher- Overrides:
acceptin classAbstractVersionMatcher- Parameters:
askedMrid- ModuleRevisionIdfoundMD- ModuleDescriptor- Returns:
- boolean
-
-