程序包 cn.taketoday.ui

接口 Model

所有已知实现类:
ConcurrentModel, ExtendedModelMap, ModelMap

public interface Model
Model that defines a holder for model attributes. Primarily designed for adding attributes to the model. Allows for accessing the overall model as a java.util.Map.
从以下版本开始:
2018-10-14 20:30
作者:
TODAY
  • 方法详细资料

    • containsAttribute

      default boolean containsAttribute(String name)
      Contains a attribute with given name
      参数:
      name - Attribute name
      返回:
      if contains the attribute
    • setAttributes

      default void setAttributes(Map<String,Object> attributes)
      Add the attributes from map
      参数:
      attributes - The attributes
    • getAttribute

      @Nullable Object getAttribute(String name)
      Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
      参数:
      name - a String specifying the name of the attribute
      返回:
      an Object containing the value of the attribute, or null if the attribute does not exist
    • setAttribute

      void setAttribute(String name, @Nullable Object value)
      Stores an attribute in this request. Attributes are reset between requests..
      参数:
      name - a String specifying the name of the attribute
      value - the Object to be stored
    • addAttribute

      Model addAttribute(String attributeName, @Nullable Object attributeValue)
      Add the supplied attribute under the supplied name.
      参数:
      attributeName - the name of the model attribute (never null)
      attributeValue - the model attribute value (can be null)
      从以下版本开始:
      4.0
    • removeAttribute

      Object removeAttribute(String name)
      Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.
      参数:
      name - a String specifying the name of the attribute to remove
      返回:
      the last value of the attribute, if any
    • asMap

      Map<String,Object> asMap()
      Convert this model to a Map
    • clear

      void clear()
      Clear all attributes
    • isEmpty

      boolean isEmpty()
      Returns true if this map contains no key-value mappings.
      返回:
      true if this map contains no key-value mappings
      从以下版本开始:
      4.0
    • getAttributeNames

      default String[] getAttributeNames()
      Return the names of all attributes.
      从以下版本开始:
      4.0
    • attributeNames

      Iterator<String> attributeNames()
      Return the names Iterator.
      从以下版本开始:
      4.0
    • addAttribute

      Model addAttribute(@Nullable Object attributeValue)
      Add the supplied attribute to this Map using a generated name.

      Note: Empty Collections are not added to the model when using this method because we cannot correctly determine the true convention name. View code should check for null rather than for empty collections as is already done by JSTL tags.

      参数:
      attributeValue - the model attribute value
      从以下版本开始:
      4.0
    • addAllAttributes

      Model addAllAttributes(@Nullable Collection<?> attributeValues)
      Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.
      从以下版本开始:
      4.0
      另请参阅:
    • addAllAttributes

      Model addAllAttributes(@Nullable Map<String,?> attributes)
      Copy all attributes in the supplied Map into this Map.
      从以下版本开始:
      4.0
      另请参阅:
    • mergeAttributes

      Model mergeAttributes(@Nullable Map<String,?> attributes)
      Copy all attributes in the supplied Map into this Map, with existing objects of the same name taking precedence (i.e. not getting replaced).
      从以下版本开始:
      4.0