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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package org.apache.archiva.admin.model.beans;
  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. import org.codehaus.jackson.annotate.JsonIgnore;
  21. import org.codehaus.jackson.annotate.JsonIgnoreProperties;
  22. import javax.xml.bind.annotation.XmlRootElement;
  23. import java.io.Serializable;
  24. /**
  25. * @author Olivier Lamy
  26. * @since 1.4-M1
  27. */
  28. @XmlRootElement( name = "legacyArtifactPath" )
  29. public class LegacyArtifactPath
  30. implements Serializable
  31. {
  32. /**
  33. * The legacy path.
  34. */
  35. private String path;
  36. /**
  37. * The artifact reference, as " [groupId] :
  38. * [artifactId] : [version] : [classifier] : [type] ".
  39. */
  40. private String artifact;
  41. public LegacyArtifactPath()
  42. {
  43. // no op
  44. }
  45. public LegacyArtifactPath( String path, String artifact )
  46. {
  47. this.path = path;
  48. this.artifact = artifact;
  49. }
  50. public String getPath()
  51. {
  52. return path;
  53. }
  54. public void setPath( String path )
  55. {
  56. this.path = path;
  57. }
  58. public String getArtifact()
  59. {
  60. return artifact;
  61. }
  62. public void setArtifact( String artifact )
  63. {
  64. this.artifact = artifact;
  65. }
  66. public boolean match( String path )
  67. {
  68. return path.equals( this.path );
  69. }
  70. @JsonIgnore
  71. public String getGroupId()
  72. {
  73. return artifact.split( ":" )[0];
  74. }
  75. @JsonIgnore
  76. public String getArtifactId()
  77. {
  78. return artifact.split( ":" )[1];
  79. }
  80. @JsonIgnore
  81. public String getVersion()
  82. {
  83. return artifact.split( ":" )[2];
  84. }
  85. @JsonIgnore
  86. public String getClassifier()
  87. {
  88. String classifier = artifact.split( ":" )[3];
  89. return classifier.length() > 0 ? classifier : null;
  90. }
  91. @JsonIgnore
  92. public String getType()
  93. {
  94. return artifact.split( ":" )[4];
  95. }
  96. @Override
  97. public boolean equals( Object o )
  98. {
  99. if ( this == o )
  100. {
  101. return true;
  102. }
  103. if ( o == null || getClass() != o.getClass() )
  104. {
  105. return false;
  106. }
  107. LegacyArtifactPath that = (LegacyArtifactPath) o;
  108. if ( path != null ? !path.equals( that.path ) : that.path != null )
  109. {
  110. return false;
  111. }
  112. return true;
  113. }
  114. @Override
  115. public int hashCode()
  116. {
  117. return path != null ? 37 + path.hashCode() : 0;
  118. }
  119. @Override
  120. public String toString()
  121. {
  122. final StringBuilder sb = new StringBuilder();
  123. sb.append( "LegacyArtifactPath" );
  124. sb.append( "{path='" ).append( path ).append( '\'' );
  125. sb.append( ", artifact='" ).append( artifact ).append( '\'' );
  126. sb.append( '}' );
  127. return sb.toString();
  128. }
  129. }