public static <T> T copyObject(final T source) {
        final ObjectMapper objectMapper = JsonUtil.getMapper();
        final TokenBuffer tb = new TokenBuffer(objectMapper, false); // or one of factory methods
        try {
            objectMapper.writeValue(tb, source);
            return (T) objectMapper.readValue(tb.asParser(), source.getClass());
        } catch (IOException e) {
            throw new RuntimeException(LogUtil.message("Error copying object {}: {}", source, e.getMessage()), e);
        }
    }
@return otherValue if it is non-null or copyNulls is true, else thisValue
stroom-util/src/main/java/stroom/util/config/PropertyUtil.java