MappingDirection { public static MappingDirection valueOf(String mappingDirection) { if (BI_DIRECTIONAL_VALUE.equals(mappingDirection)) { return BI_DIRECTIONAL; } else if (ONE_WAY_VALUE.equals(mappingDirection)) { return ONE_WAY; } else if (StringUtils.isEmpty(mappingDirection)) { return null; } throw new IllegalStateException("type should be bi-directional or one-way. " + mappingDirection); } private  MappingDirection(); static MappingDirection valueOf(String mappingDirection); static final MappingDirection BI_DIRECTIONAL; static final MappingDirection ONE_WAY; }
@Test public void testValueOf() { assertNull(MappingDirection.valueOf(null)); assertSame(MappingDirection.ONE_WAY, MappingDirection.valueOf("one-way")); assertSame(MappingDirection.BI_DIRECTIONAL, MappingDirection.valueOf("bi-directional")); }