01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: PrimaryKeyMetadata.java,v 1.11.2.3 2008/01/07 15:14:20 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.model;
10:
11: /**
12: * The metadata for a primary key field. A primary key may be specified with
13: * the {@link PrimaryKey} annotation.
14: *
15: * <p>{@code PrimaryKeyMetadata} objects are thread-safe. Multiple threads may
16: * safely call the methods of a shared {@code PrimaryKeyMetadata} object.</p>
17: *
18: * @author Mark Hayes
19: */
20: public class PrimaryKeyMetadata extends FieldMetadata {
21:
22: private static final long serialVersionUID = 2946863622972437018L;
23:
24: private String sequenceName;
25:
26: /**
27: * Used by an {@code EntityModel} to construct primary key metadata.
28: */
29: public PrimaryKeyMetadata(String name, String className,
30: String declaringClassName, String sequenceName) {
31: super (name, className, declaringClassName);
32: this .sequenceName = sequenceName;
33: }
34:
35: /**
36: * Returns the name of the sequence for assigning key values. This may be
37: * specified using the {@link PrimaryKey#sequence} annotation.
38: */
39: public String getSequenceName() {
40: return sequenceName;
41: }
42:
43: @Override
44: public boolean equals(Object other) {
45: if (other instanceof PrimaryKeyMetadata) {
46: PrimaryKeyMetadata o = (PrimaryKeyMetadata) other;
47: return super .equals(o)
48: && ClassMetadata.nullOrEqual(sequenceName,
49: o.sequenceName);
50: } else {
51: return false;
52: }
53: }
54:
55: @Override
56: public int hashCode() {
57: return super.hashCode() + ClassMetadata.hashCode(sequenceName);
58: }
59: }
|