@Test public void testCanHandle() throws Exception { TestGenericConverter converter = new TestGenericConverter(); assertTrue(converter.canHandle(1, TypeToken.of(String.class))); assertFalse(converter.canHandle(1l, TypeToken.of(String.class))); assertFalse(converter.canHandle(1, TypeToken.of(Long.class))); }
@Override public boolean canHandle(Object source, TypeToken<?> typeToken) { return sourceTypeToken.getRawType().equals(source.getClass()) && this.targetTypeToken.equals(typeToken); }
AbstractGenericConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> typeToken) { return sourceTypeToken.getRawType().equals(source.getClass()) && this.targetTypeToken.equals(typeToken); } }
AbstractGenericConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> typeToken) { return sourceTypeToken.getRawType().equals(source.getClass()) && this.targetTypeToken.equals(typeToken); } AbstractGenericConverter();  AbstractGenericConverter(int priority); }
AbstractGenericConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> typeToken) { return sourceTypeToken.getRawType().equals(source.getClass()) && this.targetTypeToken.equals(typeToken); } AbstractGenericConverter();  AbstractGenericConverter(int priority); @SuppressWarnings("unchecked") @Override Object convert(Object source, TypeToken<?> typeToken); abstract D convert(S source); @Override boolean canHandle(Object source, TypeToken<?> typeToken); TypeToken<S> getSourceTypeToken(); TypeToken<D> getTargetTypeToken(); }
AbstractGenericConverter extends AbstractConverter { @Override public boolean canHandle(Object source, TypeToken<?> typeToken) { return sourceTypeToken.getRawType().equals(source.getClass()) && this.targetTypeToken.equals(typeToken); } AbstractGenericConverter();  AbstractGenericConverter(int priority); @SuppressWarnings("unchecked") @Override Object convert(Object source, TypeToken<?> typeToken); abstract D convert(S source); @Override boolean canHandle(Object source, TypeToken<?> typeToken); TypeToken<S> getSourceTypeToken(); TypeToken<D> getTargetTypeToken();  }