GeometryType

import java.util.*;

public enum GeometryType {
NONE(0),
SPHERE(1),
CONE(2),
CYLINDER(3),
RECTANGULAR_PRISM(4),
SQUARE_PYRAMID(5),
ISOSCELES_TRIANGULAR_PRISM(6);

private int type;

private GeometryType(int type) {
this.type = type;
}

public int getType() {
return type;
}

public static GeometryType valueOf(int value) {
switch(value) {
case 1:
return SPHERE;
case 2:
return CONE;
case 3:
return CYLINDER;
case 4:
return RECTANGULAR_PRISM;
case 5:
return SQUARE_PYRAMID;
case 6:
return ISOSCELES_TRIANGULAR_PRISM;
default:
return null;
}
}

public static GeometryType nameOf(String name) {
if (name.contentEquals(“SPHERE”) || name.contentEquals(“Sphere”))
return SPHERE;
else if (name.contentEquals(“CONE”) || name.contentEquals(“Cone”))
return CONE;
else if (name.contentEquals(“CYLINDER”) || name.contentEquals(“Cylinder”))
return CYLINDER;
else if (name.contentEquals(“RECTANGULAR_PRISM”) || name.contentEquals(“RectangularPrism”))
return RECTANGULAR_PRISM;
else if (name.contentEquals(“SQUARE_PYRAMID”) || name.contentEquals(“SquarePyramid”))
return SQUARE_PYRAMID;
else if (name.contentEquals(“ISOSCELES_TRIANGULAR_PRISM”) || name.contentEquals(“IsoscelesTriangularPrism”))
return ISOSCELES_TRIANGULAR_PRISM;
else
return null;
}

public static String[] names() {
String[] names = new String[GeometryType.values().length];
for (GeometryType t : GeometryType.values())
names[t.ordinal()] = t.toString();
return names;
}
}