create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / xml / MaterialTypeDTO.java
1
2 package net.sf.openrocket.preset.xml;
3
4 import net.sf.openrocket.material.Material;
5
6 /**
7  * A mirror enum of Material.Type, for the purposes of mapping to/from an XML representation.
8  */
9 public enum MaterialTypeDTO {
10
11     LINE (Material.Type.LINE),
12     SURFACE (Material.Type.SURFACE),
13     BULK (Material.Type.BULK);
14
15     private Material.Type corollary;
16
17     private MaterialTypeDTO(final Material.Type theCorollary) {
18         corollary = theCorollary;
19     }
20
21     public static MaterialTypeDTO asDTO(Material.Type targetType) {
22         MaterialTypeDTO[] values = values();
23         for (int i = 0; i < values.length; i++) {
24             MaterialTypeDTO value = values[i];
25             if (value.corollary.equals(targetType)) {
26                 return value;
27             }
28         }
29         return BULK; //default
30     }
31
32     public Material.Type getORMaterialType() {
33         return corollary;
34     }
35 }