@Test public void json() throws Exception { ObjectMapper mapper = new ObjectMapper(); assertEquals("\"abc\"", mapper.writeValueAsString(Zone.valueOf("abc"))); assertEquals(Zone.valueOf("foo"), mapper.readValue("\"foo\"", Zone.class)); assertNull(mapper.readValue("null", Zone.class)); assertEquals("{\"zone\":\"xyz\"}", mapper.writeValueAsString(new FooPojo(Zone.valueOf("xyz")))); assertEquals(Zone.valueOf("xyz"), mapper.readValue("{\"zone\":\"xyz\"}", FooPojo.class).zone); }
public static Zone valueOf(String validValue) { Preconditions.checkArgument(isValid(validValue), "invalid zone value: %s", validValue); return new Zone(validValue); }
Zone { public static Zone valueOf(String validValue) { Preconditions.checkArgument(isValid(validValue), "invalid zone value: %s", validValue); return new Zone(validValue); } }
Zone { public static Zone valueOf(String validValue) { Preconditions.checkArgument(isValid(validValue), "invalid zone value: %s", validValue); return new Zone(validValue); } private  Zone(String value); }
Zone { public static Zone valueOf(String validValue) { Preconditions.checkArgument(isValid(validValue), "invalid zone value: %s", validValue); return new Zone(validValue); } private  Zone(String value); static boolean isValid(String rawZone); static Optional<Zone> tryFallback(String rawZone); static Zone valueOf(String validValue); @Override boolean equals(Object o); @Override int hashCode(); String value(); @Override String toString(); }
Zone { public static Zone valueOf(String validValue) { Preconditions.checkArgument(isValid(validValue), "invalid zone value: %s", validValue); return new Zone(validValue); } private  Zone(String value); static boolean isValid(String rawZone); static Optional<Zone> tryFallback(String rawZone); static Zone valueOf(String validValue); @Override boolean equals(Object o); @Override int hashCode(); String value(); @Override String toString(); static final String ZONE_PATTERN_STR; }