@Override public ObjId convertToPresentation(JObject jobj, Class<? extends ObjId> targetType, Locale locale) { if (jobj == null) return null; return jobj.getObjId(); }
@Override protected ObjId doForward(T jobj) { if (jobj == null) return null; return ((JObject)jobj).getObjId(); }
@Override public String toString() { return "ObjectDelete[objId=" + ((JObject)this.getObject()).getObjId() + "]"; } }
@Override public SizedLabel extract(JObject jobj) { return new SizedLabel("<code>" + jobj.getObjId() + "</code>", ContentMode.HTML); }
@Override public Object getValue(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); Preconditions.checkArgument(!(this.parent instanceof JComplexField), "field is a complex sub-field"); return jobj.getTransaction().readSimpleField(jobj.getObjId(), this.storageId, false); }
@Override public Counter getValue(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); return jobj.getTransaction().readCounterField(jobj.getObjId(), this.storageId, false); }
@Override @SuppressWarnings("unchecked") public void apply(JTransaction jtx, JObject jobj) { ((List<E>)jtx.readListField(jobj.getObjId(), this.getStorageId(), false)).set(this.index, this.newValue); }
@Override @SuppressWarnings("unchecked") public void apply(JTransaction jtx, JObject jobj) { ((Set<E>)jtx.readSetField(jobj.getObjId(), this.getStorageId(), false)).add(this.element); }
@Override @SuppressWarnings("unchecked") public void apply(JTransaction jtx, JObject jobj) { ((List<E>)jtx.readListField(jobj.getObjId(), this.getStorageId(), false)).add(this.index, this.element); }
@Override public List<?> getValue(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); return jobj.getTransaction().readListField(jobj.getObjId(), this.storageId, false); }
@Override public NavigableSet<?> getValue(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); return jobj.getTransaction().readSetField(jobj.getObjId(), this.storageId, false); }
@Override @SuppressWarnings("unchecked") public void apply(JTransaction jtx, JObject jobj) { ((Map<K, V>)jtx.readMapField(jobj.getObjId(), this.getStorageId(), false)).put(this.key, this.newValue); }
@Override public void apply(JTransaction jtx, JObject jobj) { jtx.readMapField(jobj.getObjId(), this.getStorageId(), false).remove(this.key); }
@Override public NavigableMap<?, ?> getValue(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); return jobj.getTransaction().readMapField(jobj.getObjId(), this.storageId, false); }
@Override protected MediaType getDefaultContentType(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); return new MediaType(this.getSupportedMediaTypes().get(0), Collections.<String, String>singletonMap(ROOT_OBJECT_ID_PARAMETER_NAME, jobj.getObjId().toString())); }
/** * Determine whether this instance still exists in its associated transaction. * * @return true if instance exists, otherwise false * @throws io.permazen.core.StaleTransactionException * if the transaction {@linkplain #getTransaction associated with this instance} is no longer usable */ default boolean exists() { return this.getTransaction().exists(this.getObjId()); }
/** * Get this instance's current schema version. Does not change this instance's schema version. * * @return the schema version of this instance * @throws io.permazen.core.DeletedObjectException * if this object does not exist in the {@link JTransaction} associated with this instance * @throws io.permazen.core.StaleTransactionException * if the transaction {@linkplain #getTransaction associated with this instance} is no longer usable */ default int getSchemaVersion() { return this.getTransaction().getSchemaVersion(this.getObjId()); }
@Override public Object get(ParseSession session) { try { return this.jfield.getValue(MethodUtil.refresh(this.jobj)); } catch (Exception e) { throw new EvalException("error reading field `" + this.jfield.getName() + "' from object " + this.jobj.getObjId() + ": " + (e.getMessage() != null ? e.getMessage() : e)); } }
@Override public void apply(JTransaction jtx, JObject jobj) { jtx.readSetField(jobj.getObjId(), this.getStorageId(), false).remove(this.element); }