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

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