@Override @JsonIgnore public <T> T get(final String key, final TypeUtil<T> type) { return type.inject(get(key)); }
/** * Loc put. * * @param key * the key * @param value * the value * @return the json node */ public JsonNode locPut(final String key, final JsonNode value) { LOG.warning("Warning, this type of State can't store JsonNodes, only Serializable objects. This JsonNode is stored as string."); locPut(key, value.toString()); return value; }
@Override public synchronized boolean putIfUnchanged(final String key, final Object newVal, final Object oldVal) { if (newVal == null || Serializable.class.isAssignableFrom(newVal.getClass())) { return locPutIfUnchanged(key, (Serializable) newVal, (Serializable) oldVal); } else if (JsonNode.class.isAssignableFrom(newVal.getClass())) { return locPutIfUnchanged(key, (JsonNode) newVal, (JsonNode) oldVal); } else { LOG.severe("Can't handle input that is not Serializable nor JsonNode."); throw new IllegalArgumentException(); } }
@Override public String toString() { final StringBuilder result = new StringBuilder(); for (final String key : keySet()) { try { result.append("'" + key + "': " + JOM.getInstance().writeValueAsString( get(key, JsonNode.class))); } catch (final JsonProcessingException e) { result.append("'" + key + "': [unprintable]"); } result.append("\n"); } return result.toString(); } }
@Id @Override public String getId() { return super.getId(); }
@Override public void delete() { if (service != null) { clear(); service.delete(this); } }
@Override @JsonIgnore public <T> T get(final String key, final Class<T> type) { return TypeUtil.inject(get(key), type); }
@Override public synchronized Object put(final String key, final Object value) { if (value == null || Serializable.class.isAssignableFrom(value.getClass())) { return locPut(key, (Serializable) value); } else if (JsonNode.class.isAssignableFrom(value.getClass())) { return locPut(key, (JsonNode) value); } else { LOG.severe("Can't handle input that is not Serializable nor JsonNode."); throw new IllegalArgumentException("Can't handle input that is not Serializable nor JsonNode."); } }
/** * Loc put if unchanged. * * @param key * the key * @param newVal * the new val * @param oldVal * the old val * @return true, if successful */ public boolean locPutIfUnchanged(final String key, final JsonNode newVal, final JsonNode oldVal) { LOG.warning("Warning, this type of State can't store JsonNodes, only Serializable objects. This JsonNode is stored as string."); return locPutIfUnchanged(key, newVal.toString(), oldVal.toString()); }
@Override @JsonIgnore public <T> T get(final String key, final JavaType type) { return TypeUtil.inject(get(key), type); }
/** * Loc put. * * @param key * the key * @param value * the value * @return the serializable */ public synchronized Serializable locPut(final String key, final Serializable value) { final ObjectMapper om = JOM.getInstance(); locPut(key, om.valueToTree(value)); return value; }
/** * Loc put if unchanged. * * @param key * the key * @param newVal * the new val * @param oldVal * the old val * @return true, if successful */ public boolean locPutIfUnchanged(final String key, final Serializable newVal, final Serializable oldVal) { final ObjectMapper om = JOM.getInstance(); return locPutIfUnchanged(key, om.valueToTree(newVal), om.valueToTree(oldVal)); }
@Override @JsonIgnore public <T> T get(final String key, final Type type) { return TypeUtil.inject(get(key), type); }
@Override @JsonIgnore public <T> T get(final TypedKey<T> typedKey) { return get(typedKey.getKey(), typedKey.getType()); }