ObjectFormatter implements IValueFormatter { @Override public String toString(Object obj, Map<String, Object> options) { return String.format("%s@%s", getPrefix((ObjectReference) obj, options), getIdPostfix((ObjectReference) obj, options)); } ObjectFormatter(BiFunction<Type, Map<String, Object>, String> typeToStringFunction); @Override String toString(Object obj, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options);  }
@Test public void testToStringDec() throws Exception { ObjectReference or = this.getObjectReference("Foo"); assertEquals("Failed to format an object.", String.format("MockType@%d", or.uniqueID()), formatter.toString(or, new HashMap<>())); }
@Test public void testToStringHex() throws Exception { ObjectReference or = this.getObjectReference("Foo"); Map<String, Object> options = formatter.getDefaultOptions(); options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.HEX); assertEquals("Failed to format an object.", String.format("MockType@%#x", or.uniqueID()), formatter.toString(or, options)); }
@Test public void testToStringOct() throws Exception { ObjectReference or = this.getObjectReference("Foo"); Map<String, Object> options = formatter.getDefaultOptions(); options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.OCT); assertEquals("Failed to format an object.", String.format("MockType@%#o", or.uniqueID()), formatter.toString(or, options)); }