]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java
Merge remote-tracking branch 'origin/master' into testing
[gpl/argeo-slc.git] / org.argeo.slc.repo / src / org / eclipse / aether / graph / Exclusion.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.aether.graph;
12
13 /**
14 * An exclusion of one or more transitive dependencies. <em>Note:</em> Instances of this class are immutable and the
15 * exposed mutators return new objects rather than changing the current instance.
16 *
17 * @see Dependency#getExclusions()
18 */
19 public final class Exclusion
20 {
21
22 private final String groupId;
23
24 private final String artifactId;
25
26 private final String classifier;
27
28 private final String extension;
29
30 /**
31 * Creates an exclusion for artifacts with the specified coordinates.
32 *
33 * @param groupId The group identifier, may be {@code null}.
34 * @param artifactId The artifact identifier, may be {@code null}.
35 * @param classifier The classifier, may be {@code null}.
36 * @param extension The file extension, may be {@code null}.
37 */
38 public Exclusion( String groupId, String artifactId, String classifier, String extension )
39 {
40 this.groupId = ( groupId != null ) ? groupId : "";
41 this.artifactId = ( artifactId != null ) ? artifactId : "";
42 this.classifier = ( classifier != null ) ? classifier : "";
43 this.extension = ( extension != null ) ? extension : "";
44 }
45
46 /**
47 * Gets the group identifier for artifacts to exclude.
48 *
49 * @return The group identifier, never {@code null}.
50 */
51 public String getGroupId()
52 {
53 return groupId;
54 }
55
56 /**
57 * Gets the artifact identifier for artifacts to exclude.
58 *
59 * @return The artifact identifier, never {@code null}.
60 */
61 public String getArtifactId()
62 {
63 return artifactId;
64 }
65
66 /**
67 * Gets the classifier for artifacts to exclude.
68 *
69 * @return The classifier, never {@code null}.
70 */
71 public String getClassifier()
72 {
73 return classifier;
74 }
75
76 /**
77 * Gets the file extension for artifacts to exclude.
78 *
79 * @return The file extension of artifacts to exclude, never {@code null}.
80 */
81 public String getExtension()
82 {
83 return extension;
84 }
85
86 @Override
87 public String toString()
88 {
89 return getGroupId() + ':' + getArtifactId() + ':' + getExtension()
90 + ( getClassifier().length() > 0 ? ':' + getClassifier() : "" );
91 }
92
93 @Override
94 public boolean equals( Object obj )
95 {
96 if ( obj == this )
97 {
98 return true;
99 }
100 else if ( obj == null || !getClass().equals( obj.getClass() ) )
101 {
102 return false;
103 }
104
105 Exclusion that = (Exclusion) obj;
106
107 return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
108 && extension.equals( that.extension ) && classifier.equals( that.classifier );
109 }
110
111 @Override
112 public int hashCode()
113 {
114 int hash = 17;
115 hash = hash * 31 + artifactId.hashCode();
116 hash = hash * 31 + groupId.hashCode();
117 hash = hash * 31 + classifier.hashCode();
118 hash = hash * 31 + extension.hashCode();
119 return hash;
120 }
121
122 }