Yet more removal/deprecation of old type narrow/widen methods.
diff --git a/src/main/java/com/fasterxml/jackson/databind/JavaType.java b/src/main/java/com/fasterxml/jackson/databind/JavaType.java
index 95b19a8..18f96c7 100644
--- a/src/main/java/com/fasterxml/jackson/databind/JavaType.java
+++ b/src/main/java/com/fasterxml/jackson/databind/JavaType.java
@@ -159,39 +159,27 @@
/* Type coercion fluent factory methods
/**********************************************************
*/
-
- /**
- * Method that can be called to do a "narrowing" conversions; that is,
- * to return a type with a raw class that is assignable to the raw
- * class of this type. If this is not possible, an
- * {@link IllegalArgumentException} is thrown.
- * If class is same as the current raw class, instance itself is
- * returned.
- */
- public JavaType narrowBy(Class<?> subclass)
- {
- // First: if same raw class, just return this instance
- if (subclass == _class) { return this; }
- // Otherwise, ensure compatibility
- _assertSubclass(subclass, _class);
-
- JavaType result = _narrow(subclass);
-
- // TODO: these checks should NOT actually be needed; above should suffice:
- if (_valueHandler != result.<Object>getValueHandler()) {
- result = result.withValueHandler(_valueHandler);
- }
- if (_typeHandler != result.<Object>getTypeHandler()) {
- result = result.withTypeHandler(_typeHandler);
- }
- return result;
- }
/**
- * More efficient version of {@link #narrowBy}, called by
- * internal framework in cases where compatibility checks
- * are to be skipped.
+ * Mutant factory method that will try to create and return a sub-type instance
+ * for known parameterized types; for other types will return `null` to indicate
+ * that no just refinement makes necessary sense, without trying to detect
+ * special status through implemented interfaces.
+ *
+ * @since 2.7
*/
+ public abstract JavaType refine(Class<?> rawType, TypeBindings bindings,
+ JavaType superClass, JavaType[] superInterfaces);
+
+ /**
+ * Legacy method used for forcing sub-typing of this type into
+ * type specified by specific type erasure.
+ * Deprecated as of 2.7 as such specializations really ought to
+ * go through {@link TypeFactory}, not directly via {@link JavaType}.
+ *
+ * @since 2.7
+ */
+ @Deprecated
public JavaType forcedNarrowBy(Class<?> subclass)
{
if (subclass == _class) { // can still optimize for simple case
@@ -210,17 +198,6 @@
protected abstract JavaType _narrow(Class<?> subclass);
- /**
- * Mutant factory method that will try to create and return a sub-type instance
- * for known parameterized types; for other types will return `null` to indicate
- * that no just refinement makes necessary sense, without trying to detect
- * special status through implemented interfaces.
- *
- * @since 2.7
- */
- public abstract JavaType refine(Class<?> rawType, TypeBindings bindings,
- JavaType superClass, JavaType[] superInterfaces);
-
/*
/**********************************************************
/* Implementation of ResolvedType API
@@ -518,18 +495,6 @@
* call chaining
*/
public abstract StringBuilder getErasedSignature(StringBuilder sb);
-
- /*
- /**********************************************************
- /* Helper methods
- /**********************************************************
- */
-
- protected void _assertSubclass(Class<?> subclass, Class<?> superClass) {
- if (!_class.isAssignableFrom(subclass)) {
- throw new IllegalArgumentException("Class "+subclass.getName()+" is not assignable to "+_class.getName());
- }
- }
/*
/**********************************************************
diff --git a/src/test/java/com/fasterxml/jackson/databind/type/TestJavaType.java b/src/test/java/com/fasterxml/jackson/databind/type/TestJavaType.java
index 5374034..010e54c 100644
--- a/src/test/java/com/fasterxml/jackson/databind/type/TestJavaType.java
+++ b/src/test/java/com/fasterxml/jackson/databind/type/TestJavaType.java
@@ -69,33 +69,6 @@
assertNull(baseType.getContentType());
assertNull(baseType.getValueHandler());
-
- /* both narrow and widen just return type itself (exact, not just
- * equal)
- * (also note that widen/narrow wouldn't work on basic simple
- * class type otherwise)
- */
- assertSame(baseType, baseType.narrowBy(BaseType.class));
-
- // Also: no narrowing for simple types (but should there be?)
- try {
- baseType.narrowBy(SubType.class);
- } catch (IllegalArgumentException e) {
- verifyException(e, "should never be called");
- }
-
- // Also, let's try assigning bogus handler
- /*
- baseType.setValueHandler("xyz"); // untyped
- assertEquals("xyz", baseType.getValueHandler());
- // illegal to re-set
- try {
- baseType.setValueHandler("foobar");
- fail("Shouldn't allow re-setting value handler");
- } catch (IllegalStateException iae) {
- verifyException(iae, "Trying to reset");
- }
- */
}
public void testArrayType()