Small cleanups
This commit is contained in:
parent
2c22015ec7
commit
acc20ee772
@ -222,7 +222,7 @@ public class Databases {
|
||||
* the provided name if unable to do so.
|
||||
*
|
||||
* @param type the material type.
|
||||
* @param baseName the base name of the material.
|
||||
* @param baseName the base name of the material.
|
||||
* @param density the density of the material.
|
||||
* @return the material object from the database or a new material.
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ import net.sf.openrocket.util.Chars;
|
||||
@XmlRootElement(name = "Material")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class MaterialDTO {
|
||||
|
||||
|
||||
@XmlElement(name = "Name")
|
||||
private String name;
|
||||
@XmlElement(name = "Density")
|
||||
@ -27,65 +27,65 @@ public class MaterialDTO {
|
||||
private MaterialTypeDTO type;
|
||||
@XmlAttribute(name = "UnitsOfMeasure")
|
||||
private String uom;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public MaterialDTO() {
|
||||
}
|
||||
|
||||
|
||||
public MaterialDTO(final Material theMaterial) {
|
||||
this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
|
||||
theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
|
||||
}
|
||||
|
||||
|
||||
public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
|
||||
name = theName;
|
||||
density = theDensity;
|
||||
type = theType;
|
||||
uom = theUom;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(final String theName) {
|
||||
name = theName;
|
||||
}
|
||||
|
||||
|
||||
public double getDensity() {
|
||||
return density;
|
||||
}
|
||||
|
||||
|
||||
public void setDensity(final double theDensity) {
|
||||
density = theDensity;
|
||||
}
|
||||
|
||||
|
||||
public MaterialTypeDTO getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public void setType(final MaterialTypeDTO theType) {
|
||||
type = theType;
|
||||
}
|
||||
|
||||
|
||||
public String getUom() {
|
||||
return uom;
|
||||
}
|
||||
|
||||
|
||||
public void setUom(final String theUom) {
|
||||
uom = theUom;
|
||||
}
|
||||
|
||||
|
||||
Material asMaterial() {
|
||||
return Databases.findMaterial(type.getORMaterialType(), name, density);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Special directive to the JAXB system. After the object is parsed from xml,
|
||||
* we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the
|
||||
* we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the
|
||||
* opposite transformation as done in beforeMarshal.
|
||||
* @param unmarshaller
|
||||
* @param parent
|
||||
@ -97,7 +97,7 @@ public class MaterialDTO {
|
||||
uom = uom.replace('3', Chars.CUBED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Special directive to the JAXB system. Before the object is serialized into xml,
|
||||
* we strip out the special unicode characters for cubed and squared so they appear
|
||||
|
@ -20,8 +20,7 @@ public enum MaterialTypeDTO {
|
||||
|
||||
public static MaterialTypeDTO asDTO(Material.Type targetType) {
|
||||
MaterialTypeDTO[] values = values();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
MaterialTypeDTO value = values[i];
|
||||
for (MaterialTypeDTO value : values) {
|
||||
if (value.corollary.equals(targetType)) {
|
||||
return value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user