• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/db-4.7.25.NC/java/src/com/sleepycat/persist/model/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: PrimaryKeyMetadata.java,v 1.1 2008/02/07 17:12:28 mark Exp $
7 */
8
9package com.sleepycat.persist.model;
10
11
12/**
13 * The metadata for a primary key field.  A primary key may be specified with
14 * the {@link PrimaryKey} annotation.
15 *
16 * <p>{@code PrimaryKeyMetadata} objects are thread-safe.  Multiple threads may
17 * safely call the methods of a shared {@code PrimaryKeyMetadata} object.</p>
18 *
19 * @author Mark Hayes
20 */
21public class PrimaryKeyMetadata extends FieldMetadata {
22
23    private static final long serialVersionUID = 2946863622972437018L;
24
25    private String sequenceName;
26
27    /**
28     * Used by an {@code EntityModel} to construct primary key metadata.
29     */
30    public PrimaryKeyMetadata(String name,
31                              String className,
32                              String declaringClassName,
33                              String sequenceName) {
34        super(name, className, declaringClassName);
35        this.sequenceName = sequenceName;
36    }
37
38    /**
39     * Returns the name of the sequence for assigning key values.  This may be
40     * specified using the {@link PrimaryKey#sequence} annotation.
41     */
42    public String getSequenceName() {
43        return sequenceName;
44    }
45
46    @Override
47    public boolean equals(Object other) {
48        if (other instanceof PrimaryKeyMetadata) {
49            PrimaryKeyMetadata o = (PrimaryKeyMetadata) other;
50            return super.equals(o) &&
51                   ClassMetadata.nullOrEqual(sequenceName, o.sequenceName);
52        } else {
53            return false;
54        }
55    }
56
57    @Override
58    public int hashCode() {
59        return super.hashCode() + ClassMetadata.hashCode(sequenceName);
60    }
61}
62