@Test public void shouldPerformTheCoercionAsExpected() { try { final NodeCache nodeCache = new NodeCache(); final IJsonNode result = TypeCoercer.INSTANCE.coerce(this.value, nodeCache, this.targetType); Assert.assertTrue(String.format("%s->%s=%s", this.value.getClass(), this.targetType, result.getClass()), this.targetType.isInstance(result)); Assert.assertEquals(String.format("%s->%s=%s", this.value, this.targetType, result), this.expectedResult, result); } catch (final CoercionException e) { Assert.assertTrue(String.format("%s->%s=Exception", this.value, this.targetType), this.expectedResult == CONVERSION_ERROR); } }
public <From extends IJsonNode, To extends IJsonNode> To coerce(final From node, final NodeCache nodeCache, final Class<To> targetType) { final To result = this.coerce(node, nodeCache, targetType, null); if (result == null) throw new CoercionException(String.format("Cannot coerce %s to %s", node, targetType)); return result; }
TypeCoercer { public <From extends IJsonNode, To extends IJsonNode> To coerce(final From node, final NodeCache nodeCache, final Class<To> targetType) { final To result = this.coerce(node, nodeCache, targetType, null); if (result == null) throw new CoercionException(String.format("Cannot coerce %s to %s", node, targetType)); return result; } }
TypeCoercer { public <From extends IJsonNode, To extends IJsonNode> To coerce(final From node, final NodeCache nodeCache, final Class<To> targetType) { final To result = this.coerce(node, nodeCache, targetType, null); if (result == null) throw new CoercionException(String.format("Cannot coerce %s to %s", node, targetType)); return result; } TypeCoercer(); }
TypeCoercer { public <From extends IJsonNode, To extends IJsonNode> To coerce(final From node, final NodeCache nodeCache, final Class<To> targetType) { final To result = this.coerce(node, nodeCache, targetType, null); if (result == null) throw new CoercionException(String.format("Cannot coerce %s to %s", node, targetType)); return result; } TypeCoercer(); @SuppressWarnings({ "rawtypes", "unchecked" }) void addCoercers(final Class<To> targetClass, final Map<?, TypeMapper<?, To>> coercers); To coerce(final From node, final NodeCache nodeCache,
			final Class<To> targetType); @SuppressWarnings("unchecked") To coerce(final From node, final NodeCache nodeCache,
			final Class<To> targetClass, final To defaultValue); @SuppressWarnings("unchecked") To coerce(final From node, final NodeCache nodeCache,
			final To defaultValue); void setCoercer(final Class<From> from, final Class<To> to,
			final TypeMapper<From, To> coercer); }
TypeCoercer { public <From extends IJsonNode, To extends IJsonNode> To coerce(final From node, final NodeCache nodeCache, final Class<To> targetType) { final To result = this.coerce(node, nodeCache, targetType, null); if (result == null) throw new CoercionException(String.format("Cannot coerce %s to %s", node, targetType)); return result; } TypeCoercer(); @SuppressWarnings({ "rawtypes", "unchecked" }) void addCoercers(final Class<To> targetClass, final Map<?, TypeMapper<?, To>> coercers); To coerce(final From node, final NodeCache nodeCache,
			final Class<To> targetType); @SuppressWarnings("unchecked") To coerce(final From node, final NodeCache nodeCache,
			final Class<To> targetClass, final To defaultValue); @SuppressWarnings("unchecked") To coerce(final From node, final NodeCache nodeCache,
			final To defaultValue); void setCoercer(final Class<From> from, final Class<To> to,
			final TypeMapper<From, To> coercer); static final List<Class<? extends INumericNode>> NUMERIC_TYPES; static final TypeCoercer INSTANCE; }