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.
|
* the provided name if unable to do so.
|
||||||
*
|
*
|
||||||
* @param type the material type.
|
* @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.
|
* @param density the density of the material.
|
||||||
* @return the material object from the database or a new 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")
|
@XmlRootElement(name = "Material")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MaterialDTO {
|
public class MaterialDTO {
|
||||||
|
|
||||||
@XmlElement(name = "Name")
|
@XmlElement(name = "Name")
|
||||||
private String name;
|
private String name;
|
||||||
@XmlElement(name = "Density")
|
@XmlElement(name = "Density")
|
||||||
@ -27,65 +27,65 @@ public class MaterialDTO {
|
|||||||
private MaterialTypeDTO type;
|
private MaterialTypeDTO type;
|
||||||
@XmlAttribute(name = "UnitsOfMeasure")
|
@XmlAttribute(name = "UnitsOfMeasure")
|
||||||
private String uom;
|
private String uom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public MaterialDTO() {
|
public MaterialDTO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialDTO(final Material theMaterial) {
|
public MaterialDTO(final Material theMaterial) {
|
||||||
this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
|
this(theMaterial.getName(), theMaterial.getDensity(), MaterialTypeDTO.asDTO(theMaterial.getType()),
|
||||||
theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
|
theMaterial.getType().getUnitGroup().getDefaultUnit().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
|
public MaterialDTO(final String theName, final double theDensity, final MaterialTypeDTO theType, final String theUom) {
|
||||||
name = theName;
|
name = theName;
|
||||||
density = theDensity;
|
density = theDensity;
|
||||||
type = theType;
|
type = theType;
|
||||||
uom = theUom;
|
uom = theUom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(final String theName) {
|
public void setName(final String theName) {
|
||||||
name = theName;
|
name = theName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDensity() {
|
public double getDensity() {
|
||||||
return density;
|
return density;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDensity(final double theDensity) {
|
public void setDensity(final double theDensity) {
|
||||||
density = theDensity;
|
density = theDensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialTypeDTO getType() {
|
public MaterialTypeDTO getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(final MaterialTypeDTO theType) {
|
public void setType(final MaterialTypeDTO theType) {
|
||||||
type = theType;
|
type = theType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUom() {
|
public String getUom() {
|
||||||
return uom;
|
return uom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUom(final String theUom) {
|
public void setUom(final String theUom) {
|
||||||
uom = theUom;
|
uom = theUom;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material asMaterial() {
|
Material asMaterial() {
|
||||||
return Databases.findMaterial(type.getORMaterialType(), name, density);
|
return Databases.findMaterial(type.getORMaterialType(), name, density);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special directive to the JAXB system. After the object is parsed from xml,
|
* 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.
|
* opposite transformation as done in beforeMarshal.
|
||||||
* @param unmarshaller
|
* @param unmarshaller
|
||||||
* @param parent
|
* @param parent
|
||||||
@ -97,7 +97,7 @@ public class MaterialDTO {
|
|||||||
uom = uom.replace('3', Chars.CUBED);
|
uom = uom.replace('3', Chars.CUBED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special directive to the JAXB system. Before the object is serialized into xml,
|
* 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
|
* 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) {
|
public static MaterialTypeDTO asDTO(Material.Type targetType) {
|
||||||
MaterialTypeDTO[] values = values();
|
MaterialTypeDTO[] values = values();
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (MaterialTypeDTO value : values) {
|
||||||
MaterialTypeDTO value = values[i];
|
|
||||||
if (value.corollary.equals(targetType)) {
|
if (value.corollary.equals(targetType)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user