@Test public void canHandle() throws Exception { assertTrue(converter.canHandle("5", TypeToken.of(Hours.class))); assertTrue(converter.canHandle(100, TypeToken.of(Days.class))); assertTrue(converter.canHandle(100, TypeToken.of(Years.class))); assertFalse(converter.canHandle("2017-09-03", TypeToken.of(Months.class))); }
@Override public boolean canHandle(Object source, TypeToken<?> targetTypeToken) { return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class) && ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class)))); }
JodaTimeSingleFieldPeriodConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> targetTypeToken) { return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class) && ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class)))); } }
JodaTimeSingleFieldPeriodConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> targetTypeToken) { return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class) && ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class)))); }  }
JodaTimeSingleFieldPeriodConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> targetTypeToken) { return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class) && ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class)))); }  @Override Object convert(Object source, TypeToken<?> targetTypeToken); @Override boolean canHandle(Object source, TypeToken<?> targetTypeToken); }
JodaTimeSingleFieldPeriodConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> targetTypeToken) { return targetTypeToken.isSubtypeOf(BaseSingleFieldPeriod.class) && ((source instanceof Number) || (stringToNumberConverter.canHandle(source, TypeToken.of(Long.class)))); }  @Override Object convert(Object source, TypeToken<?> targetTypeToken); @Override boolean canHandle(Object source, TypeToken<?> targetTypeToken);  }