Boroughs { public static final Borough fromCode(String code) { return findFirst((Borough b) -> b.getCode().equalsIgnoreCase(code)); } private  Boroughs(); static final Borough fromCode(String code); static final Borough fromName(String name); static int parseInt(String boroughCodeOrName); static final Borough findFirst(Predicate<? super Borough> predicate); static final Borough MANHATTAN; static final Borough BRONX; static final Borough BROOKLYN; static final Borough QUEENS; static final Borough STATEN_ISLAND; static final int UNPARSABLE_BOROUGH_CODE_SENTINEL_VALUE; static final List<Borough> THE_FIVE_BOROUGHS; }
@Test void testFromCode() { assertSame(Boroughs.MANHATTAN, Boroughs.fromCode("1")); assertSame(Boroughs.BRONX, Boroughs.fromCode("2")); assertSame(Boroughs.BROOKLYN, Boroughs.fromCode("3")); assertSame(Boroughs.QUEENS, Boroughs.fromCode("4")); assertSame(Boroughs.STATEN_ISLAND, Boroughs.fromCode("5")); assertNull(Boroughs.fromCode(" 1")); assertNull(Boroughs.fromCode("8")); assertNull(Boroughs.fromCode("woof")); }