DisplayData implements Serializable { public static @Nullable Type inferType(@Nullable Object value) { return Type.tryInferFrom(value); } private  DisplayData(Map<Identifier, Item> entries); static DisplayData none(); static DisplayData from(HasDisplayData component); static @Nullable Type inferType(@Nullable Object value); @JsonValue Collection<Item> items(); Map<Identifier, Item> asMap(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); @Override String toString(); static ItemSpec<String> item(String key, @Nullable String value); static ItemSpec<?> item(String key, @Nullable ValueProvider<?> value); static ItemSpec<Integer> item(String key, @Nullable Integer value); static ItemSpec<Long> item(String key, @Nullable Long value); static ItemSpec<Float> item(String key, @Nullable Float value); static ItemSpec<Double> item(String key, @Nullable Double value); static ItemSpec<Boolean> item(String key, @Nullable Boolean value); static ItemSpec<Instant> item(String key, @Nullable Instant value); static ItemSpec<Duration> item(String key, @Nullable Duration value); static ItemSpec<Class<T>> item(String key, @Nullable Class<T> value); static ItemSpec<T> item(String key, Type type, @Nullable T value);  }
@Test public void testKnownTypeInference() { assertEquals(DisplayData.Type.INTEGER, DisplayData.inferType(1234)); assertEquals(DisplayData.Type.INTEGER, DisplayData.inferType(1234L)); assertEquals(DisplayData.Type.FLOAT, DisplayData.inferType(12.3)); assertEquals(DisplayData.Type.FLOAT, DisplayData.inferType(12.3f)); assertEquals(DisplayData.Type.BOOLEAN, DisplayData.inferType(true)); assertEquals(DisplayData.Type.TIMESTAMP, DisplayData.inferType(Instant.now())); assertEquals(DisplayData.Type.DURATION, DisplayData.inferType(Duration.millis(1234))); assertEquals(DisplayData.Type.JAVA_CLASS, DisplayData.inferType(DisplayDataTest.class)); assertEquals(DisplayData.Type.STRING, DisplayData.inferType("hello world")); assertEquals(null, DisplayData.inferType(null)); assertEquals(null, DisplayData.inferType(new Object() {})); }