}
private void fireEvent(int event, List listeners, ResolutionNode node,
Artifact replacement, VersionRange newRange) {
for (Iterator i = listeners.iterator(); i.hasNext();) {
ResolutionListener listener = (ResolutionListener) i.next();
switch (event) {
case ResolutionListener.TEST_ARTIFACT:
listener.testArtifact(node.getArtifact());
break;
case ResolutionListener.PROCESS_CHILDREN:
listener.startProcessChildren(node.getArtifact());
break;
case ResolutionListener.FINISH_PROCESSING_CHILDREN:
listener.endProcessChildren(node.getArtifact());
break;
case ResolutionListener.INCLUDE_ARTIFACT:
listener.includeArtifact(node.getArtifact());
break;
case ResolutionListener.OMIT_FOR_NEARER:
String version = node.getArtifact().getVersion();
String replacementVersion = replacement.getVersion();
if (version != null ? !version.equals(replacementVersion)
: replacementVersion != null) {
listener.omitForNearer(node.getArtifact(), replacement);
}
break;
case ResolutionListener.OMIT_FOR_CYCLE:
listener.omitForCycle(node.getArtifact());
break;
case ResolutionListener.UPDATE_SCOPE:
listener
.updateScope(node.getArtifact(), replacement.getScope());
break;
case ResolutionListener.UPDATE_SCOPE_CURRENT_POM:
listener.updateScopeCurrentPom(node.getArtifact(), replacement
.getScope());
break;
case ResolutionListener.MANAGE_ARTIFACT:
listener.manageArtifact(node.getArtifact(), replacement);
break;
case ResolutionListener.SELECT_VERSION_FROM_RANGE:
listener.selectVersionFromRange(node.getArtifact());
break;
case ResolutionListener.RESTRICT_RANGE:
if (node.getArtifact().getVersionRange().hasRestrictions()
|| replacement.getVersionRange().hasRestrictions()) {
listener.restrictRange(node.getArtifact(), replacement,
newRange);
}
break;
default:
throw new IllegalStateException("Unknown event: " + event);