]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.support/src/org/argeo/slc/aether/ArtifactIdComparator.java
6aa0ec69a18920ed40d8ea74e741d963ed136030
[gpl/argeo-slc.git] / org.argeo.slc.support / src / org / argeo / slc / aether / ArtifactIdComparator.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.aether;
17
18 import java.util.Comparator;
19 import java.util.TreeMap;
20 import java.util.TreeSet;
21
22 import org.eclipse.aether.artifact.Artifact;
23
24 /**
25 * Compare two artifacts, for use in {@link TreeSet} / {@link TreeMap}, consider
26 * artifactId first THEN groupId
27 */
28 public class ArtifactIdComparator implements Comparator<Artifact> {
29 public int compare(Artifact o1, Artifact o2) {
30 if (o1.getArtifactId().equals(o2.getArtifactId()))
31 return o1.getGroupId().compareTo(o2.getGroupId());
32 return o1.getArtifactId().compareTo(o2.getArtifactId());
33 }
34
35 }