Skip to content

Commit

Permalink
AbstractConverter: make deprecated API consistent
Browse files Browse the repository at this point in the history
The canConvert(Class, Class) signature is deprecated in the Converter interface, so let's deprecate the overridden method as well, as it's the case for canConvert(Class, Type) already.
  • Loading branch information
imagejan committed Oct 30, 2020
1 parent 80d0a38 commit f1dd9ba
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/scijava/convert/AbstractConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,9 @@ public boolean canConvert(final Object src, final Type dest) {
public boolean canConvert(final Object src, final Class<?> dest) {
if (src == null) return false;
final Class<?> srcClass = src.getClass();

return canConvert(srcClass, dest);
}

@Override
public boolean canConvert(final Class<?> src, final Class<?> dest) {
if (src == null) return false;
final Class<?> saneSrc = Types.box(src);
final Class<?> saneDest = Types.box(dest);
return Types.isAssignable(saneSrc, getInputType()) &&
Types.isAssignable(getOutputType(), saneDest);
}

@Override
public Object convert(final Object src, final Type dest) {
final Class<?> destClass = Types.raw(dest);
Expand Down Expand Up @@ -148,6 +138,16 @@ public Class<ConversionRequest> getType() {

// -- Deprecated API --

@Override
@Deprecated
public boolean canConvert(final Class<?> src, final Class<?> dest) {
if (src == null) return false;
final Class<?> saneSrc = Types.box(src);
final Class<?> saneDest = Types.box(dest);
return Types.isAssignable(saneSrc, getInputType()) &&
Types.isAssignable(getOutputType(), saneDest);
}

@Override
@Deprecated
public boolean canConvert(final Class<?> src, final Type dest) {
Expand Down

0 comments on commit f1dd9ba

Please sign in to comment.