You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LegacyArtifactPath.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package org.apache.archiva.configuration;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. /**
  21. * Class LegacyArtifactPath.
  22. *
  23. * @version $Revision$ $Date$
  24. */
  25. @SuppressWarnings( "all" )
  26. public class LegacyArtifactPath
  27. implements java.io.Serializable
  28. {
  29. //--------------------------/
  30. //- Class/Member Variables -/
  31. //--------------------------/
  32. /**
  33. *
  34. * The legacy path.
  35. *
  36. */
  37. private String path;
  38. /**
  39. *
  40. * The artifact reference, as " [groupId] :
  41. * [artifactId] : [version] : [classifier] : [type] ".
  42. *
  43. */
  44. private String artifact;
  45. //-----------/
  46. //- Methods -/
  47. //-----------/
  48. /**
  49. * Get the artifact reference, as " [groupId] : [artifactId] :
  50. * [version] : [classifier] : [type] ".
  51. *
  52. * @return String
  53. */
  54. public String getArtifact()
  55. {
  56. return this.artifact;
  57. } //-- String getArtifact()
  58. /**
  59. * Get the legacy path.
  60. *
  61. * @return String
  62. */
  63. public String getPath()
  64. {
  65. return this.path;
  66. } //-- String getPath()
  67. /**
  68. * Set the artifact reference, as " [groupId] : [artifactId] :
  69. * [version] : [classifier] : [type] ".
  70. *
  71. * @param artifact
  72. */
  73. public void setArtifact( String artifact )
  74. {
  75. this.artifact = artifact;
  76. } //-- void setArtifact( String )
  77. /**
  78. * Set the legacy path.
  79. *
  80. * @param path
  81. */
  82. public void setPath( String path )
  83. {
  84. this.path = path;
  85. } //-- void setPath( String )
  86. public boolean match( String path )
  87. {
  88. return path.equals( this.path );
  89. }
  90. public String getGroupId()
  91. {
  92. return artifact.split( ":" )[0];
  93. }
  94. public String getArtifactId()
  95. {
  96. return artifact.split( ":" )[1];
  97. }
  98. public String getVersion()
  99. {
  100. return artifact.split( ":" )[2];
  101. }
  102. public String getClassifier()
  103. {
  104. String classifier = artifact.split( ":" )[3];
  105. return classifier.length() > 0 ? classifier : null;
  106. }
  107. public String getType()
  108. {
  109. return artifact.split( ":" )[4];
  110. }
  111. @Override
  112. public boolean equals( Object o )
  113. {
  114. if ( this == o )
  115. {
  116. return true;
  117. }
  118. if ( o == null || getClass() != o.getClass() )
  119. {
  120. return false;
  121. }
  122. LegacyArtifactPath that = (LegacyArtifactPath) o;
  123. if ( path != null ? !path.equals( that.path ) : that.path != null )
  124. {
  125. return false;
  126. }
  127. return true;
  128. }
  129. @Override
  130. public int hashCode()
  131. {
  132. return path != null ? 37 + path.hashCode() : 0;
  133. }
  134. }