StringObjectFormatter extends ObjectFormatter implements IValueFormatter { @Override public boolean acceptType(Type type, Map<String, Object> options) { return type != null && (type.signature().charAt(0) == STRING || type.signature().equals(STRING_SIGNATURE)); } StringObjectFormatter(); @Override Map<String, Object> getDefaultOptions(); @Override String toString(Object value, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options); static final String MAX_STRING_LENGTH_OPTION; }
@Test public void testAcceptType() throws Exception { ObjectReference foo = this.getObjectReference("Foo"); assertFalse("Should not accept null type.", formatter.acceptType(null, new HashMap<>())); assertFalse("Should not accept Foo type.", formatter.acceptType(foo.referenceType(), new HashMap<>())); ObjectReference str = this.getObjectReference("java.lang.String"); assertTrue("Should accept String type.", formatter.acceptType(str.referenceType(), new HashMap<>())); ObjectReference clz = this.getObjectReference("java.lang.Class"); assertFalse("Should not accept Class type.", formatter.acceptType(clz.referenceType(), new HashMap<>())); LocalVariable list = this.getLocalVariable("strList"); assertFalse("Should not accept List type.", formatter.acceptType(list.type(), new HashMap<>())); LocalVariable arrays = this.getLocalVariable("arrays"); assertFalse("Should not accept array type.", formatter.acceptType(arrays.type(), new HashMap<>())); }