org.apache.tapestry5.beaneditor

## Interface BeanModel<T>

- All Known Implementing Classes:
    BeanModelImpl

      public interface BeanModel<T>

  Provides the information necessary to build a user interface to view, create or edit an instance of a particular type. BeanModels are not thread-safe, they are also not serializable. Here, and in `PropertyModel`, the term "propertyName" is used for simplicitly. However, a full property expression may be utilized when adding new properties to an existing BeanModel.
  See Also:
    `BeanModelSource`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `PropertyModel` | `add(RelativePosition position, String existingPropertyName, String propertyName)` Adds a new property to the model (as with `add(String)`), ordered before or after an existing property.
    `PropertyModel` | `add(RelativePosition position, String existingPropertyName, String propertyName, PropertyConduit conduit)` Adds a new property to the model, ordered before or after an existing property.
    `PropertyModel` | `add(String propertyName)` Adds a new property to the model, returning its mutable model for further refinement.
    `PropertyModel` | `add(String propertyName, PropertyConduit conduit)` Adds a new, synthetic property to the model, returning its mutable model for further refinement.
    `PropertyModel` | `addEmpty(String propertyName)` Adds an empty property (one with no property conduit).
    `PropertyModel` | `addExpression(String propertyName, String expression)` Adds a new synthetic property to the model, returning its mutable model for further refinement.
    `BeanModel<T>` | `exclude(String... propertyNames)` Removes the named properties from the model, if present.
    `PropertyModel` | `get(String propertyName)` Returns the named model.
    `Class<T>` | `getBeanType()` Returns the type of bean for which this model was initially created.
    `PropertyModel` | `getById(String propertyId)` Returns the identified model.
    `List<String>` | `getPropertyNames()` Returns a list of the editable properties of the bean, in presentation order.
    `BeanModel<T>` | `include(String... propertyNames)` Re-orders the properties of the model into the specified order.
    `T` | `newInstance()` Creates a new bean instance.
    `BeanModel<T>` | `reorder(String... propertyNames)` Re-orders the properties of the model into the specified order.

- - ### Method Detail

    - #### getBeanType

          Class<T> getBeanType()

      Returns the type of bean for which this model was initially created.

    - #### newInstance

          T newInstance()

      Creates a new bean instance. This is based on `ObjectLocator.autobuild(Class)`, so a public constructor will be used, and dependencies injected.
      Returns:
        new instance of the bean

    - #### getPropertyNames

          List<String> getPropertyNames()

      Returns a list of the editable properties of the bean, in presentation order.

    - #### get

          PropertyModel get(String propertyName)

      Returns the named model.
      Parameters:
        `propertyName` - name of property to retrieve model for (case is ignored)
      Returns:
        the model for the property
      Throws:
        `RuntimeException` - if the bean editor model does not have a property model for the provided name

    - #### getById

          PropertyModel getById(String propertyId)

      Returns the identified model. Property ids are a stripped version of the property name. Case is ignored.
      Parameters:
        `propertyId` - matched caselessly against `PropertyModel.getId()`
      Throws:
        `RuntimeException` - if the bean editor model does not have a property model with the indicated id

    - #### add

          PropertyModel add(String propertyName)

      Adds a new property to the model, returning its mutable model for further refinement. The property is added to the end of the list of properties. The property must be real (but may have been excluded if there was no datatype associated with the property). To add a synthetic property, use `add(String, org.apache.tapestry5.PropertyConduit)`
      Parameters:
        `propertyName` - name of property to add
      Returns:
        the new property model (for further configuration)
      Throws:
        `RuntimeException` - if the property already exists

    - #### addExpression

          PropertyModel addExpression(String propertyName,
                                      String expression)

      Adds a new synthetic property to the model, returning its mutable model for further refinement. The property is added to the end of the list of properties.
      Parameters:
        `propertyName` - name of property to add
        `expression` - expression for the property
      Returns:
        the new property model (for further configuration)
      Throws:
        `RuntimeException` - if the property already exists
      Since:
        5.3

    - #### addEmpty

          PropertyModel addEmpty(String propertyName)

      Adds an empty property (one with no property conduit).
      Parameters:
        `propertyName` - name of property to add
      Returns:
        the new property model (for further configuration)
      Throws:
        `RuntimeException` - if the property already exists
      Since:
        5.3

    - #### add

          PropertyModel add(RelativePosition position,
                            String existingPropertyName,
                            String propertyName)

      Adds a new property to the model (as with `add(String)`), ordered before or after an existing property.
      Parameters:
        `position` - controls whether the new property is ordered before or after the existing property
        `existingPropertyName` - the name of an existing property (this must exist)
        `propertyName` - the new property to add
      Returns:
        the new property model (for further configuration)
      Throws:
        `RuntimeException` - if the existing property does not exist, or if the new property already does exist

    - #### add

          PropertyModel add(RelativePosition position,
                            String existingPropertyName,
                            String propertyName,
                            PropertyConduit conduit)

      Adds a new property to the model, ordered before or after an existing property.
      Parameters:
        `position` - controls whether the new property is ordered before or after the existing property
        `existingPropertyName` - the name of an existing property (this must exist)
        `propertyName` - the new property to add
        `conduit` - conduit used to read or update the property; this may be null for a synthetic or placeholder property
      Returns:
        the new property model (for further configuration)
      Throws:
        `RuntimeException` - if the existing property does not exist, or if the new property already does exist

    - #### add

          PropertyModel add(String propertyName,
                            PropertyConduit conduit)

      Adds a new, synthetic property to the model, returning its mutable model for further refinement.
      Parameters:
        `propertyName` - name of property to add
        `conduit` - the conduit used to read or update the property; this may be null for a synthetic or placeholder property. Instead of passing null, please invoke `addEmpty(String)`.
      Returns:
        the model for the property
      Throws:
        `RuntimeException` - if the property already exists
      See Also:
        `addExpression(String, String)`

    - #### exclude

          BeanModel<T> exclude(String... propertyNames)

      Removes the named properties from the model, if present. It is not considered an error to remove a property that does not exist.
      Parameters:
        `propertyNames` - the names of properties to be removed (case insensitive)
      Returns:
        the model for further modifications

    - #### reorder

          BeanModel<T> reorder(String... propertyNames)

      Re-orders the properties of the model into the specified order. Existing properties that are not indicated are retained, but ordered to the end of the list.
      Parameters:
        `propertyNames` - property names in order they should be displayed (case insensitive)
      Returns:
        the model for further modifications

    - #### include

          BeanModel<T> include(String... propertyNames)

      Re-orders the properties of the model into the specified order. Existing properties that are not indicated are removed.
      Parameters:
        `propertyNames` - the names of properties to be retained
      Returns:
        the model for further modifications

5.6.0 - Copyright © 2003-2020 The Apache Software Foundation.