Skip to content

Commit

Permalink
HSEARCH-3222 Replace FromIndexFieldValueConverter#getConvertedType() …
Browse files Browse the repository at this point in the history
…by #isConvertedTypeAssignableTo()
  • Loading branch information
gsmet committed Oct 23, 2018
1 parent ca79a95 commit 65a18f3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
Expand Up @@ -15,9 +15,15 @@
public interface FromIndexFieldValueConverter<F, V> {

/**
* @return The type of the converted value.
* Check whether converted values can be assigned to the given type.
* <p>
* This method is generally implemented like this:
* {@code return superTypeCandidate.isAssignableFrom( TheConvertedType.class )}.
* @param superTypeCandidate A candidate type for assignment of converted values.
* @return {@code true} if the converted type {@link V} is a subtype of {@code superTypeCandidate},
* {@code false} otherwise.
*/
Class<?> getConvertedType();
boolean isConvertedTypeAssignableTo(Class<?> superTypeCandidate);

/**
* @param value The index field value to convert.
Expand Down
Expand Up @@ -22,8 +22,7 @@ public F convert(F value) {
}

@Override
public Class<?> getConvertedType() {
return fieldType;
public boolean isConvertedTypeAssignableTo(Class<?> superTypeCandidate) {
return superTypeCandidate.isAssignableFrom( fieldType );
}

}
Expand Up @@ -84,6 +84,6 @@ public boolean isProjectionCompatibleWith(Class<?> projectionType) {
return projectionType.isAssignableFrom( indexFieldType );
}

return projectionType.isAssignableFrom( projectionFromIndexConverter.getConvertedType() );
return projectionFromIndexConverter.isConvertedTypeAssignableTo( projectionType );
}
}
Expand Up @@ -37,8 +37,8 @@ public static <T> FromIndexFieldValueConverter<T, ValueWrapper<T>> fromIndexFiel
return new FromIndexFieldValueConverter<T, ValueWrapper<T>>() {

@Override
public Class<?> getConvertedType() {
return ValueWrapper.class;
public boolean isConvertedTypeAssignableTo(Class<?> superTypeCandidate) {
return superTypeCandidate.isAssignableFrom( ValueWrapper.class );
}

@Override
Expand Down
Expand Up @@ -43,8 +43,8 @@ public boolean isCompatibleWith(ValueBridge<?, ?> other) {
private static class ISBNFromIndexFieldValueConverter implements FromIndexFieldValueConverter<String, ISBN> {

@Override
public Class<ISBN> getConvertedType() {
return ISBN.class;
public boolean isConvertedTypeAssignableTo(Class<?> superTypeCandidate) {
return superTypeCandidate.isAssignableFrom( ISBN.class );
}

@Override
Expand Down
Expand Up @@ -50,8 +50,8 @@ public boolean isCompatibleWith(ValueBridge<?, ?> other) {
private class DefaultEnumFromIndexFieldValueConverter implements FromIndexFieldValueConverter<String, V> {

@Override
public Class<?> getConvertedType() {
return enumType;
public boolean isConvertedTypeAssignableTo(Class<?> superTypeCandidate) {
return superTypeCandidate.isAssignableFrom( enumType );
}

@Override
Expand Down

0 comments on commit 65a18f3

Please sign in to comment.