RelationshipType { public static RelationshipType valueOf(String relationshipType) { if (CUMULATIVE_VALUE.equals(relationshipType)) { return CUMULATIVE; } else if (NON_CUMULATIVE_VALUE.equals(relationshipType)) { return NON_CUMULATIVE; } else if (StringUtils.isEmpty(relationshipType)) { return null; } throw new IllegalStateException("relationship-type should be cumulative or non-cumulative. " + relationshipType); } private  RelationshipType(); static RelationshipType valueOf(String relationshipType); static final RelationshipType CUMULATIVE; static final RelationshipType NON_CUMULATIVE; }
@Test public void testValueOf() { assertNull(RelationshipType.valueOf("")); assertNull(RelationshipType.valueOf(null)); assertEquals(RelationshipType.CUMULATIVE, RelationshipType.valueOf("cumulative")); assertEquals(RelationshipType.NON_CUMULATIVE, RelationshipType.valueOf("non-cumulative")); }