TypedPropertyUtils { @SuppressWarnings("IfCanBeSwitch") public static TypedProperty create(@NonNull String type) throws JSONException { if (BooleanTypedProperty.TYPE.equals(type)) { return new BooleanTypedProperty(); } else if (DateTimeTypedProperty.TYPE.equals(type)) { return new DateTimeTypedProperty(); } else if (DoubleTypedProperty.TYPE.equals(type)) { return new DoubleTypedProperty(); } else if (LongTypedProperty.TYPE.equals(type)) { return new LongTypedProperty(); } else if (StringTypedProperty.TYPE.equals(type)) { return new StringTypedProperty(); } throw new JSONException("Unsupported type: " + type); }  @SuppressWarnings("IfCanBeSwitch") static TypedProperty create(@NonNull String type); static List<TypedProperty> read(JSONObject object);  }
@Test public void createValidTypedProperty() throws JSONException { assertTrue(TypedPropertyUtils.create(BooleanTypedProperty.TYPE) instanceof BooleanTypedProperty); assertTrue(TypedPropertyUtils.create(DateTimeTypedProperty.TYPE) instanceof DateTimeTypedProperty); assertTrue(TypedPropertyUtils.create(DoubleTypedProperty.TYPE) instanceof DoubleTypedProperty); assertTrue(TypedPropertyUtils.create(LongTypedProperty.TYPE) instanceof LongTypedProperty); assertTrue(TypedPropertyUtils.create(StringTypedProperty.TYPE) instanceof StringTypedProperty); }
@Test(expected = JSONException.class) public void createInvalidTypedProperty() throws JSONException { new TypedPropertyUtils().create("Something"); }