This project has retired. For details please refer to its Attic page.
TempKeyPK xref
View Javadoc
1   package org.apache.juddi.model;
2   /*
3    * Copyright 2001-2008 The Apache Software Foundation.
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  import javax.persistence.Column;
19  import javax.persistence.Embeddable;
20  
21  import org.apache.commons.lang.builder.HashCodeBuilder;
22  
23  /**
24   * @author <a href="mailto:kstam@apache.org">Kurt Stam</a>
25   */
26  
27  @Embeddable
28  public class TempKeyPK implements java.io.Serializable {
29  	
30  	private static final long serialVersionUID = 790951819871694597L;
31  	private String entityKey;
32  	private String txId;
33  	
34  	public TempKeyPK(){
35  	}
36  	
37  	@Column(name = "entity_key", nullable = false, length = 255)
38  	public String getEntityKey() {
39  		return entityKey;
40  	}
41  	public void setEntityKey(String entityKey) {
42  		this.entityKey = entityKey;
43  	}
44  
45  	@Column(name = "tx_id", nullable = false, length = 255)
46  	public String getTxId() {
47  		return txId;
48  	}
49  	public void setTxId(String txId) {
50  		this.txId = txId;
51  	}
52  	
53  	public int compareTo(TempKeyPK o) {
54  		if (o==null || o.getEntityKey()==null || o.getTxId()==null) return 0;
55  		if (o.getEntityKey().equals(getEntityKey()) && o.getTxId().equals(getTxId())) return 1;
56  		else return 0;
57  	}
58  	
59  	@Override
60  	public boolean equals(Object obj) {
61  		if (obj!=null && obj instanceof TempKeyPK) {
62  			int i = compareTo((TempKeyPK) obj);
63  			if (i==1) return true;
64  			else return false;
65  		} else {
66  			return false;
67  		}
68  	}
69  	
70  	@Override
71  	public int hashCode() {
72          return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
73              append(getTxId()).
74              append(getEntityKey()).
75              toHashCode();
76      }
77  }
78  
79