@Override public NavigableSetConverter<?, ?> getConverter(JTransaction jtx) { final Converter<?, ?> elementConverter = this.elementField.getConverter(jtx); return elementConverter != null ? this.createConverter(elementConverter) : null; }
@Override public ListConverter<?, ?> getConverter(JTransaction jtx) { final Converter<?, ?> elementConverter = this.elementField.getConverter(jtx); return elementConverter != null ? this.createConverter(elementConverter) : null; }
@Override public NavigableMapConverter<?, ?, ?, ?> getConverter(JTransaction jtx) { Converter<?, ?> keyConverter = this.keyField.getConverter(jtx); Converter<?, ?> valueConverter = this.valueField.getConverter(jtx); if (keyConverter == null && valueConverter == null) return null; if (keyConverter == null) keyConverter = Converter.<Object>identity(); if (valueConverter == null) valueConverter = Converter.<Object>identity(); return this.createConverter(keyConverter, valueConverter); }
/** * Read a simple field. This returns the value returned by {@link Transaction#readSimpleField Transaction.readSimpleField()} * with {@link ObjId}s converted into {@link JObject}s, etc. * * <p> * This method is used by generated {@link io.permazen.annotation.JField @JField} getter override methods * and not normally invoked directly by user code. * * @param id ID of the object containing the field * @param storageId storage ID of the {@link JSimpleField} * @param updateVersion true to first automatically update the object's schema version, false to not change it * @return value of the field in the object * @throws StaleTransactionException if this transaction is no longer usable * @throws DeletedObjectException if the object does not exist in this transaction * @throws UnknownFieldException if no {@link JSimpleField} corresponding to {@code storageId} exists * @throws TypeNotInSchemaVersionException if {@code updateVersion} is true but the object has a type * that does not exist in this instance's schema version * @throws NullPointerException if {@code id} is null */ public Object readSimpleField(ObjId id, int storageId, boolean updateVersion) { return this.convert(this.jdb.getJField(id, storageId, JSimpleField.class).getConverter(this), this.tx.readSimpleField(id, storageId, updateVersion)); }
@Override public Integer caseJSimpleField(JSimpleField field1) { if (!(jfield2 instanceof JSimpleField)) return 0; final JSimpleField field2 = (JSimpleField)jfield2; final FieldType<?> fieldType1 = field1.getFieldType(); final FieldType<?> fieldType2 = field2.getFieldType(); if (!fieldType1.equals(fieldType2)) return 0; Object value1 = field1.getValue(jobj1); Object value2 = field2.getValue(jobj2); final Converter<?, ?> converter1 = field1.getConverter(jobj1.getTransaction()); if (converter1 != null) value1 = this.convert(converter1.reverse(), value1); final Converter<?, ?> converter2 = field2.getConverter(jobj2.getTransaction()); if (converter2 != null) value2 = this.convert(converter2.reverse(), value2); return this.compare(fieldType1, value1, value2); }
/** * Write a simple field. This writes the value via {@link Transaction#writeSimpleField Transaction.writeSimpleField()} * after converting {@link JObject}s into {@link ObjId}s, etc. * * <p> * This method is used by generated {@link io.permazen.annotation.JField @JField} setter override methods * and not normally invoked directly by user code. * * @param jobj object containing the field * @param storageId storage ID of the {@link JSimpleField} * @param value new value for the field * @param updateVersion true to first automatically update the object's schema version, false to not change it * @throws StaleTransactionException if this transaction is no longer usable * @throws DeletedObjectException if {@code jobj} does not exist in this transaction * @throws UnknownFieldException if no {@link JSimpleField} corresponding to {@code storageId} exists * @throws TypeNotInSchemaVersionException if {@code updateVersion} is true but {@code jobj} has a type * that does not exist in this instance's schema version * @throws IllegalArgumentException if {@code value} is not an appropriate value for the field * @throws NullPointerException if {@code jobj} is null */ public void writeSimpleField(JObject jobj, int storageId, Object value, boolean updateVersion) { JTransaction.registerJObject(jobj); // handle possible re-entrant object cache load final ObjId id = jobj.getObjId(); final Converter<?, ?> converter = this.jdb.getJField(id, storageId, JSimpleField.class).getConverter(this); if (converter != null) value = this.convert(converter.reverse(), value); this.tx.writeSimpleField(id, storageId, value, updateVersion); }