This project has retired. For details please refer to its
        
        Attic page.
      
1   package org.apache.archiva.metadata.repository.cassandra.model;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
23  
24  import java.io.Serializable;
25  
26  
27  
28  
29  
30  
31  public class Namespace
32      implements Serializable
33  {
34  
35      private String name;
36  
37      private String repositoryName;
38  
39      public Namespace()
40      {
41          
42      }
43  
44  
45      public Namespace( String id, Repository repository )
46      {
47          this.name = id;
48          this.repositoryName = repository.getName();
49      }
50  
51  
52      public String getName()
53      {
54          return name;
55      }
56  
57      public void setName( String name )
58      {
59          this.name = name;
60      }
61  
62      public Repository getRepository()
63      {
64          return new Repository( this.repositoryName );
65      }
66  
67      public void setRepository( Repository repository )
68      {
69          this.repositoryName = repository.getName();
70      }
71  
72      @Override
73      public boolean equals( Object o )
74      {
75          if ( this == o )
76          {
77              return true;
78          }
79          if ( o == null || getClass() != o.getClass() )
80          {
81              return false;
82          }
83  
84          Namespace../../../../../org/apache/archiva/metadata/repository/cassandra/model/Namespace.html#Namespace">Namespace namespace = (Namespace) o;
85  
86          if ( !name.equals( namespace.name ) )
87          {
88              return false;
89          }
90          if ( !repositoryName.equals( namespace.repositoryName ) )
91          {
92              return false;
93          }
94  
95          return true;
96      }
97  
98      @Override
99      public int hashCode()
100     {
101         int result = name.hashCode();
102         result = 31 * result + repositoryName.hashCode();
103         return result;
104     }
105 
106     @Override
107     public String toString()
108     {
109         final StringBuilder sb = new StringBuilder( "Namespace{" );
110         sb.append( ", name='" ).append( name ).append( '\'' );
111         sb.append( ", repository='" ).append( repositoryName ).append( '\'' );
112         sb.append( '}' );
113         return sb.toString();
114     }
115 
116     public static class KeyBuilder
117     {
118 
119         private String namespace;
120 
121         private String repositoryId;
122 
123         public KeyBuilder()
124         {
125 
126         }
127 
128         public KeyBuilder withNamespace( Namespace namespace )
129         {
130             this.namespace = namespace.getName();
131             this.repositoryId = namespace.getRepository().getName();
132             return this;
133         }
134 
135         public KeyBuilder withNamespace( String namespace )
136         {
137             this.namespace = namespace;
138             return this;
139         }
140 
141         public KeyBuilder withRepositoryId( String repositoryId )
142         {
143             this.repositoryId = repositoryId;
144             return this;
145         }
146 
147         public String build()
148         {
149             
150             return CassandraUtils.generateKey( this.repositoryId, this.namespace );
151         }
152     }
153 }