create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / motor / ThrustCurveMotorPlaceholder.java
1 package net.sf.openrocket.motor;
2
3 import net.sf.openrocket.util.BugException;
4 import net.sf.openrocket.util.Coordinate;
5
6 public class ThrustCurveMotorPlaceholder implements Motor {
7         
8         private final Motor.Type type;
9         private final String manufacturer;
10         private final String designation;
11         private final double diameter;
12         private final double length;
13         private final String digest;
14         private final double delay;
15         private final double launchMass;
16         private final double emptyMass;
17         
18         
19         public ThrustCurveMotorPlaceholder(Type type, String manufacturer, String designation, double diameter, double length,
20                         String digest, double delay, double launchMass, double emptyMass) {
21                 this.type = type;
22                 this.manufacturer = manufacturer;
23                 this.designation = designation;
24                 this.diameter = diameter;
25                 this.length = length;
26                 this.digest = digest;
27                 this.delay = delay;
28                 this.launchMass = launchMass;
29                 this.emptyMass = emptyMass;
30         }
31         
32         
33         @Override
34         public Type getMotorType() {
35                 return type;
36         }
37         
38         public String getManufacturer() {
39                 return manufacturer;
40         }
41         
42         @Override
43         public String getDesignation() {
44                 return designation;
45         }
46         
47         @Override
48         public String getDesignation(double designationDelay) {
49                 return designation + "-" + ThrustCurveMotor.getDelayString(designationDelay);
50         }
51         
52         @Override
53         public String getDescription() {
54                 return "";
55         }
56         
57         @Override
58         public double getDiameter() {
59                 return diameter;
60         }
61         
62         @Override
63         public double getLength() {
64                 return length;
65         }
66         
67         @Override
68         public String getDigest() {
69                 return digest;
70         }
71         
72         public double getDelay() {
73                 return delay;
74         }
75         
76         @Override
77         public MotorInstance getInstance() {
78                 throw new BugException("Called getInstance on PlaceholderMotor");
79         }
80         
81         @Override
82         public Coordinate getLaunchCG() {
83                 return new Coordinate(length / 2, 0, 0, launchMass);
84         }
85         
86         @Override
87         public Coordinate getEmptyCG() {
88                 return new Coordinate(length / 2, 0, 0, emptyMass);
89         }
90         
91         @Override
92         public double getBurnTimeEstimate() {
93                 return Double.NaN;
94         }
95         
96         @Override
97         public double getAverageThrustEstimate() {
98                 return Double.NaN;
99         }
100         
101         @Override
102         public double getMaxThrustEstimate() {
103                 return Double.NaN;
104         }
105         
106         @Override
107         public double getTotalImpulseEstimate() {
108                 return Double.NaN;
109         }
110
111         @Override
112         public int hashCode() {
113                 final int prime = 31;
114                 int result = 1;
115                 long temp;
116                 temp = Double.doubleToLongBits(delay);
117                 result = prime * result + (int) (temp ^ (temp >>> 32));
118                 result = prime * result
119                                 + ((designation == null) ? 0 : designation.hashCode());
120                 temp = Double.doubleToLongBits(diameter);
121                 result = prime * result + (int) (temp ^ (temp >>> 32));
122                 result = prime * result + ((digest == null) ? 0 : digest.hashCode());
123                 temp = Double.doubleToLongBits(emptyMass);
124                 result = prime * result + (int) (temp ^ (temp >>> 32));
125                 temp = Double.doubleToLongBits(launchMass);
126                 result = prime * result + (int) (temp ^ (temp >>> 32));
127                 temp = Double.doubleToLongBits(length);
128                 result = prime * result + (int) (temp ^ (temp >>> 32));
129                 result = prime * result
130                                 + ((manufacturer == null) ? 0 : manufacturer.hashCode());
131                 result = prime * result + ((type == null) ? 0 : type.hashCode());
132                 return result;
133         }
134
135         @Override
136         public boolean equals(Object obj) {
137                 if (this == obj)
138                         return true;
139                 if (obj == null)
140                         return false;
141                 if (getClass() != obj.getClass())
142                         return false;
143                 ThrustCurveMotorPlaceholder other = (ThrustCurveMotorPlaceholder) obj;
144                 if (Double.doubleToLongBits(delay) != Double
145                                 .doubleToLongBits(other.delay))
146                         return false;
147                 if (designation == null) {
148                         if (other.designation != null)
149                                 return false;
150                 } else if (!designation.equals(other.designation))
151                         return false;
152                 if (Double.doubleToLongBits(diameter) != Double
153                                 .doubleToLongBits(other.diameter))
154                         return false;
155                 if (digest == null) {
156                         if (other.digest != null)
157                                 return false;
158                 } else if (!digest.equals(other.digest))
159                         return false;
160                 if (Double.doubleToLongBits(emptyMass) != Double
161                                 .doubleToLongBits(other.emptyMass))
162                         return false;
163                 if (Double.doubleToLongBits(launchMass) != Double
164                                 .doubleToLongBits(other.launchMass))
165                         return false;
166                 if (Double.doubleToLongBits(length) != Double
167                                 .doubleToLongBits(other.length))
168                         return false;
169                 if (manufacturer == null) {
170                         if (other.manufacturer != null)
171                                 return false;
172                 } else if (!manufacturer.equals(other.manufacturer))
173                         return false;
174                 if (type != other.type)
175                         return false;
176                 return true;
177         }
178
179
180         @Override
181         public String toString() {
182                 return "ThrustCurveMotorPlaceholder [manufacturer=" + manufacturer
183                                 + ", designation=" + designation + "]";
184         }
185         
186 }