1 package org.apache.archiva.metadata.repository.cassandra.model;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
24 import javax.persistence.Column;
25 import javax.persistence.Id;
26 import java.io.Serializable;
29 * @author Olivier Lamy
33 implements Serializable
36 @Column(name = "projectKey")
37 private String projectKey;
39 @Column(name = "projectId")
40 private String projectId;
43 @Column(name = "repository")
44 private Namespace namespace;
51 public Project( String projectKey, String projectId, Namespace namespace )
53 this.projectId = projectId;
54 this.projectKey = projectKey;
55 this.namespace = namespace;
58 public String getProjectKey()
63 public void setProjectKey( String projectKey )
65 this.projectKey = projectKey;
68 public Namespace getNamespace()
73 public void setNamespace( Namespace namespace )
75 this.namespace = namespace;
78 public String getProjectId()
83 public void setProjectId( String projectId )
85 this.projectId = projectId;
89 public boolean equals( Object o )
95 if ( o == null || getClass() != o.getClass() )
100 Project project = (Project) o;
102 if ( !projectKey.equals( project.projectKey ) )
106 if ( !namespace.equals( project.namespace ) )
115 public int hashCode()
117 int result = projectKey.hashCode();
118 result = 31 * result + namespace.hashCode();
123 public String toString()
125 final StringBuilder sb = new StringBuilder( "Project{" );
126 sb.append( "projectKey='" ).append( projectKey ).append( '\'' );
127 sb.append( ", projectId='" ).append( projectId ).append( '\'' );
128 sb.append( ", namespace=" ).append( namespace );
130 return sb.toString();
133 public static class KeyBuilder
136 private Namespace namespace;
138 private String projectId;
145 public KeyBuilder withNamespace( Namespace namespace )
147 this.namespace = namespace;
151 public KeyBuilder withProjectId( String projectId )
153 this.projectId = projectId;
158 public String build()
160 // FIXME add some controls
161 return CassandraUtils.generateKey( new Namespace.KeyBuilder().withNamespace( this.namespace ).build(),