c437ed4c38e3f79b6030a5eaf0272754c57c9f2a
[debian/openrocket] / core / src / net / sf / openrocket / preset / xml / BaseComponentDTO.java
1
2 package net.sf.openrocket.preset.xml;
3
4 import net.sf.openrocket.preset.ComponentPreset;
5
6 import javax.xml.bind.annotation.XmlAccessType;
7 import javax.xml.bind.annotation.XmlAccessorType;
8 import javax.xml.bind.annotation.XmlElement;
9
10 /**
11  * Base class for the external representation of all component presets.
12  */
13 @XmlAccessorType(XmlAccessType.FIELD)
14 public abstract class BaseComponentDTO {
15
16     @XmlElement(name = "Manufacturer")
17     private String manufacturer;
18     @XmlElement(name = "PartNumber")
19     private String partNo;
20     @XmlElement(name = "Description")
21     private String description;
22     @XmlElement(name = "Material")
23     private String material;
24     @XmlElement(name = "Mass")
25     private double mass;
26
27     /**
28      * Default constructor.
29      */
30     protected BaseComponentDTO() {
31     }
32
33     /**
34      * Constructor.
35      *
36      * @param preset  the preset to use to pull data values out of
37      *
38      * @throws net.sf.openrocket.util.BugException thrown if the expected body tube keys are not in the preset
39      */
40     protected BaseComponentDTO(final ComponentPreset preset) {
41         setManufacturer(preset.getManufacturer().getSimpleName());
42         setPartNo(preset.getPartNo());
43         setDescription(preset.get(ComponentPreset.DESCRIPTION));
44         setMaterial(preset.get(ComponentPreset.MATERIAL).getName());
45         if (preset.has(ComponentPreset.MASS)) {
46             setMass(preset.get(ComponentPreset.MASS));
47         }
48     }
49
50     public String getManufacturer() {
51         return manufacturer;
52     }
53
54     public void setManufacturer(final String theManufacturer) {
55         manufacturer = theManufacturer;
56     }
57
58     public String getPartNo() {
59         return partNo;
60     }
61
62     public void setPartNo(final String thePartNo) {
63         partNo = thePartNo;
64     }
65
66     public String getDescription() {
67         return description;
68     }
69
70     public void setDescription(final String theDescription) {
71         description = theDescription;
72     }
73
74     public String getMaterial() {
75         return material;
76     }
77
78     public void setMaterial(final String theMaterial) {
79         material = theMaterial;
80     }
81
82     public double getMass() {
83         return mass;
84     }
85
86     public void setMass(final double theMass) {
87         mass = theMass;
88     }
89 }