create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / xml / ShapeDTO.java
1
2 package net.sf.openrocket.preset.xml;
3
4 import net.sf.openrocket.rocketcomponent.Transition;
5
6 import javax.xml.bind.annotation.XmlEnum;
7
8 /**
9  * A mirror class to Transition.Shape to adapt that class to/from XML.
10  */
11 @XmlEnum(String.class)
12 public enum ShapeDTO {
13
14     CONICAL (Transition.Shape.CONICAL),
15     OGIVE   (Transition.Shape.OGIVE),
16     ELLIPSOID (Transition.Shape.ELLIPSOID),
17     POWER (Transition.Shape.POWER),
18     PARABOLIC (Transition.Shape.PARABOLIC),
19     HAACK (Transition.Shape.HAACK);
20
21     private Transition.Shape corollary;
22
23     private ShapeDTO(Transition.Shape theShape) {
24         corollary = theShape;
25     }
26
27     public static ShapeDTO asDTO(Transition.Shape targetShape) {
28         ShapeDTO[] values = values();
29         for (int i = 0; i < values.length; i++) {
30             ShapeDTO value = values[i];
31             if (value.corollary.equals(targetShape)) {
32                 return value;
33             }
34         }
35         return ELLIPSOID; //default
36     }
37
38     public Transition.Shape getORShape() {
39         return corollary;
40     }
41 }