Class UnmodifiableEntityWrapper

java.lang.Object
ch.tocco.nice2.persist.core.api.entity.entitywrappers.AbstractEntityWrapper
ch.tocco.nice2.persist.core.api.entity.entitywrappers.UnmodifiableEntityWrapper
All Implemented Interfaces:
EntityReference, Entity

public class UnmodifiableEntityWrapper extends AbstractEntityWrapper
Wrapper for making an entity unmodifiable. All modifying methods throw an UnsupportedOperationException.

Note that relations are still modifiable.

Use Entities.unmodifiableEntity(myEntity)

  • Constructor Details

    • UnmodifiableEntityWrapper

      public UnmodifiableEntityWrapper(Entity entity)
  • Method Details

    • setValue

      public final void setValue(String field, @Nullable @Nullable Object value)
      Description copied from interface: Entity
      Set the value of a field.

      In the current implementation no content validation is made on this method call - other than null on a non-nullable field. Validation happens when storing, when all values have been set.

      The value must either be in the correct data type, or convertible. To be convertible there must be a ch.tocco.nice2.types.spi.Converter contributed. Note that not all kinds of conversions that seem obvious at first are registered, for example there is no string to integer converter and thus a value like "" won't work and set 0 on an int field. Setting an int 0 on a long field works though because there is an int to long type converter.

      Specified by:
      setValue in interface Entity
      Overrides:
      setValue in class AbstractEntityWrapper
      Parameters:
      field - The name of the field.
      value - The new value in the expected data type, or in a conversible type of it. Throws ch.tocco.nice2.security.UnauthorizedException If the user does not have the permission to set/change the value.
    • delete

      public final void delete()
      Description copied from interface: Entity
      Delete the entity.
      Specified by:
      delete in interface Entity
      Overrides:
      delete in class AbstractEntityWrapper
    • joinTx

      public final void joinTx()
      Description copied from interface: Entity
      Joins the current transaction.
      Specified by:
      joinTx in interface Entity
      Overrides:
      joinTx in class AbstractEntityWrapper
    • isUpdatable

      public final boolean isUpdatable()
      Description copied from interface: Entity
      Determine whether the entity is updatable.
      Specified by:
      isUpdatable in interface Entity
      Overrides:
      isUpdatable in class AbstractEntityWrapper
      Returns:
      true, if the entity is updatable, false, if it's read-only.