public ObjectMessage(Class<?> clazz) { if (clazz == null) { throw new IllegalArgumentException("clazz is null"); } setObjectClass(clazz); }
public ObjectMessage(Object object) { if (object == null) { throw new IllegalArgumentException("object is null"); } setObjectClass(object.getClass()); final String msg; try { msg = mapper.writeValueAsString(object); setMessage(msg); } catch (JsonProcessingException e) { throw new IllegalStateException("Object cannot be parsed as JSON.", e); } }
public Object getObject() { Class<?> clazz = getObjectClass(); if (clazz == null) { throw new IllegalStateException("Do not know what the class is that represents the JSON data"); } try { return mapper.readValue(getMessage(), clazz); } catch (IOException e) { throw new IllegalStateException("JSON message cannot be converted to object.", e); } } }
public ObjectMessage(Object object) { if (object == null) { throw new IllegalArgumentException("object is null"); } setObjectClass(object.getClass()); final String msg; try { msg = mapper.writeValueAsString(object); setMessage(msg); } catch (JsonProcessingException e) { throw new IllegalStateException("Object cannot be parsed as JSON.", e); } }
public Object getObject() { Class<?> clazz = getObjectClass(); if (clazz == null) { throw new IllegalStateException("Do not know what the class is that represents the JSON data"); } try { return mapper.readValue(getMessage(), clazz); } catch (IOException e) { throw new IllegalStateException("JSON message cannot be converted to object.", e); } } }
public ObjectMessage(Class<?> clazz) { if (clazz == null) { throw new IllegalArgumentException("clazz is null"); } setObjectClass(clazz); }