public static Variation attemptToGetAsVariant ( String part ) { // Annoyingly JAXB won't bind Variation as an enum, so we have to do this manually. // TODO - can we do something more clever... eg make StoneTypes, WoodTypes etc inherit from an XSD baseclass, // and have an object in the schemas that returns a list, so we can just iterate... try { StoneTypes var = StoneTypes . valueOf ( part . toUpperCase ( ) ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { WoodTypes var = WoodTypes . valueOf ( part . toUpperCase ( ) ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { FlowerTypes var = FlowerTypes . fromValue ( part ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { EntityTypes var = EntityTypes . fromValue ( part ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { MonsterEggTypes var = MonsterEggTypes . fromValue ( part ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { ShapeTypes var = ShapeTypes . fromValue ( part ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } try { HalfTypes var = HalfTypes . fromValue ( part ) ; if ( var != null ) { Variation bv = new Variation ( ) ; bv . setValue ( var . value ( ) ) ; return bv ; } } catch ( Exception e ) { // Does nothing. } return null ; }
Attempt to parse string as a Variation