@Test public void testBooleanConverter() { assertTrue("Failure returning same object", this.schema.convert(true).equals(Boolean.TRUE)); assertTrue("Failure returning same object", this.schema.convert(false).equals(Boolean.FALSE)); assertTrue("Failure parsing true", this.schema.convert("true").equals(Boolean.TRUE)); assertTrue("Failure parsing false", this.schema.convert("false").equals(Boolean.FALSE)); }
@Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if (stringData.equals("false")) { return Boolean.FALSE; } else { throw new IllegalArgumentException(stringData + " cannot be parsed to a boolean"); } } throw new IllegalArgumentException(value + " is not a boolean"); }
BooleanSchema extends PrimitiveSchema { @Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if (stringData.equals("false")) { return Boolean.FALSE; } else { throw new IllegalArgumentException(stringData + " cannot be parsed to a boolean"); } } throw new IllegalArgumentException(value + " is not a boolean"); } }
BooleanSchema extends PrimitiveSchema { @Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if (stringData.equals("false")) { return Boolean.FALSE; } else { throw new IllegalArgumentException(stringData + " cannot be parsed to a boolean"); } } throw new IllegalArgumentException(value + " is not a boolean"); } BooleanSchema(); }
BooleanSchema extends PrimitiveSchema { @Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if (stringData.equals("false")) { return Boolean.FALSE; } else { throw new IllegalArgumentException(stringData + " cannot be parsed to a boolean"); } } throw new IllegalArgumentException(value + " is not a boolean"); } BooleanSchema(); @Override Object convert(Object value); }
BooleanSchema extends PrimitiveSchema { @Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if (stringData.equals("false")) { return Boolean.FALSE; } else { throw new IllegalArgumentException(stringData + " cannot be parsed to a boolean"); } } throw new IllegalArgumentException(value + " is not a boolean"); } BooleanSchema(); @Override Object convert(Object value);  }