01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.plugins.version;
19:
20: import java.util.Comparator;
21:
22: import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
23: import org.apache.ivy.core.module.id.ModuleRevisionId;
24: import org.apache.ivy.core.settings.IvySettings;
25: import org.apache.ivy.plugins.IvySettingsAware;
26: import org.apache.ivy.util.Checks;
27:
28: public abstract class AbstractVersionMatcher implements VersionMatcher,
29: IvySettingsAware {
30: private String name;
31:
32: private IvySettings settings;
33:
34: public AbstractVersionMatcher() {
35: }
36:
37: public AbstractVersionMatcher(String name) {
38: this .name = name;
39: }
40:
41: public String getName() {
42: return name;
43: }
44:
45: public void setName(String name) {
46: this .name = name;
47: }
48:
49: public boolean needModuleDescriptor(ModuleRevisionId askedMrid,
50: ModuleRevisionId foundMrid) {
51: return false;
52: }
53:
54: public boolean accept(ModuleRevisionId askedMrid,
55: ModuleDescriptor foundMD) {
56: return accept(askedMrid, foundMD.getResolvedModuleRevisionId());
57: }
58:
59: /**
60: * This method should be overriden in most cases, because it uses the default contract to return
61: * 1 when it's not possible to know which revision is greater.
62: */
63: public int compare(ModuleRevisionId askedMrid,
64: ModuleRevisionId foundMrid, Comparator staticComparator) {
65: return 0;
66: }
67:
68: public String toString() {
69: return getName();
70: }
71:
72: public IvySettings getSettings() {
73: return settings;
74: }
75:
76: public void setSettings(IvySettings settings) {
77: Checks.checkNotNull(settings, "settings");
78: this.settings = settings;
79: }
80:
81: }
|