@Test void canUnmarshall() throws GenieException { final String source = "[\"one\",\"two\",\"three\"]"; final TypeReference<List<String>> list = new TypeReference<List<String>>() { }; Assertions .assertThat(JsonUtils.unmarshall(source, list)) .isEqualTo(Lists.newArrayList("one", "two", "three")); Assertions.assertThat(JsonUtils.unmarshall(null, list)).isEqualTo(Lists.newArrayList()); }
public static <T extends Collection> T unmarshall( final String source, final TypeReference<T> typeReference ) throws GenieException { try { if (StringUtils.isNotBlank(source)) { return GenieObjectMapper.getMapper().readValue(source, typeReference); } else { return GenieObjectMapper.getMapper().readValue("[]", typeReference); } } catch (final IOException ioe) { throw new GenieServerException("Failed to read JSON value", ioe); } }
JsonUtils { public static <T extends Collection> T unmarshall( final String source, final TypeReference<T> typeReference ) throws GenieException { try { if (StringUtils.isNotBlank(source)) { return GenieObjectMapper.getMapper().readValue(source, typeReference); } else { return GenieObjectMapper.getMapper().readValue("[]", typeReference); } } catch (final IOException ioe) { throw new GenieServerException("Failed to read JSON value", ioe); } } }
JsonUtils { public static <T extends Collection> T unmarshall( final String source, final TypeReference<T> typeReference ) throws GenieException { try { if (StringUtils.isNotBlank(source)) { return GenieObjectMapper.getMapper().readValue(source, typeReference); } else { return GenieObjectMapper.getMapper().readValue("[]", typeReference); } } catch (final IOException ioe) { throw new GenieServerException("Failed to read JSON value", ioe); } } protected  JsonUtils(); }
JsonUtils { public static <T extends Collection> T unmarshall( final String source, final TypeReference<T> typeReference ) throws GenieException { try { if (StringUtils.isNotBlank(source)) { return GenieObjectMapper.getMapper().readValue(source, typeReference); } else { return GenieObjectMapper.getMapper().readValue("[]", typeReference); } } catch (final IOException ioe) { throw new GenieServerException("Failed to read JSON value", ioe); } } protected  JsonUtils(); static String marshall(final Object value); static T unmarshall(
        final String source,
        final TypeReference<T> typeReference
    ); @Nonnull static List<String> splitArguments(final String commandArgs); @Nullable static String joinArguments(final List<String> commandArgs); }
JsonUtils { public static <T extends Collection> T unmarshall( final String source, final TypeReference<T> typeReference ) throws GenieException { try { if (StringUtils.isNotBlank(source)) { return GenieObjectMapper.getMapper().readValue(source, typeReference); } else { return GenieObjectMapper.getMapper().readValue("[]", typeReference); } } catch (final IOException ioe) { throw new GenieServerException("Failed to read JSON value", ioe); } } protected  JsonUtils(); static String marshall(final Object value); static T unmarshall(
        final String source,
        final TypeReference<T> typeReference
    ); @Nonnull static List<String> splitArguments(final String commandArgs); @Nullable static String joinArguments(final List<String> commandArgs);  }