1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: Part.java,v 12.7 2008/01/08 20:58:31 bostic Exp $
7 */
8
9package collections.ship.sentity;
10
11import java.io.Serializable;
12
13/**
14 * A Part represents the combined key/data pair for a part entity.
15 *
16 * <p> In this sample, Part is created from the stored key/data entry using a
17 * TupleSerialEntityBinding.  See {@link SampleViews.PartBinding} for details.
18 * </p>
19 *
20 * <p> The binding is "tricky" in that it uses this class for both the stored
21 * data entry and the combined entity object.  To do this, the key field(s) are
22 * transient and are set by the binding after the data object has been
23 * deserialized. This avoids the use of a PartData class completely. </p>
24 *
25 * <p> Since this class is used directly for data storage, it must be
26 * Serializable. </p>
27 *
28 * @author Mark Hayes
29 */
30public class Part implements Serializable {
31
32    private transient String number;
33    private String name;
34    private String color;
35    private Weight weight;
36    private String city;
37
38    public Part(String number, String name, String color, Weight weight,
39                String city) {
40
41        this.number = number;
42        this.name = name;
43        this.color = color;
44        this.weight = weight;
45        this.city = city;
46    }
47
48    /**
49     * Set the transient key fields after deserializing.  This method is only
50     * called by data bindings.
51     */
52    final void setKey(String number) {
53
54        this.number = number;
55    }
56
57    public final String getNumber() {
58
59        return number;
60    }
61
62    public final String getName() {
63
64        return name;
65    }
66
67    public final String getColor() {
68
69        return color;
70    }
71
72    public final Weight getWeight() {
73
74        return weight;
75    }
76
77    public final String getCity() {
78
79        return city;
80    }
81
82    public String toString() {
83
84        return "[Part: number=" + number +
85               " name=" + name +
86               " color=" + color +
87               " weight=" + weight +
88               " city=" + city + ']';
89    }
90}
91