1 package net.sf.openrocket.preset;
3 import net.sf.openrocket.motor.Manufacturer;
4 import net.sf.openrocket.rocketcomponent.RocketComponent;
7 * A model for a preset component.
9 * A preset component contains a component class type, manufacturer information,
10 * part information, and a method that returns a prototype of the preset component.
12 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
14 public abstract class ComponentPreset {
16 private final Manufacturer manufacturer;
17 private final String partNo;
18 private final String partDescription;
19 private final RocketComponent prototype;
22 public ComponentPreset(Manufacturer manufacturer, String partNo, String partDescription,
23 RocketComponent prototype) {
24 this.manufacturer = manufacturer;
26 this.partDescription = partDescription;
27 this.prototype = prototype.copy();
29 if (prototype.getParent() != null) {
30 throw new IllegalArgumentException("Prototype component cannot have a parent");
32 if (prototype.getChildCount() > 0) {
33 throw new IllegalArgumentException("Prototype component cannot have children");
39 * Return the component class that this preset defines.
41 public Class<? extends RocketComponent> getComponentClass() {
42 return prototype.getClass();
46 * Return the manufacturer of this preset component.
48 public Manufacturer getManufacturer() {
53 * Return the part number. This is the part identifier (e.g. "BT-50").
55 public String getPartNo() {
60 * Return the part description. This is a longer description of the component.
62 public String getPartDescription() {
63 return partDescription;
67 * Return a prototype component. This component may be modified freely.
69 public RocketComponent getPrototype() {
70 return prototype.copy();