Class EntityView

java.lang.Object
com.foreach.across.modules.entity.views.EntityView
All Implemented Interfaces:
org.springframework.ui.Model

public class EntityView extends Object implements org.springframework.ui.Model
Represents both the view and the backing model for a generated entity output page. The Model implementation is extended with some type-safe methods for passing data between EntityViewProcessor instances if so used.

Supports different types of resulting view:

Author:
Arne Vandamme
See Also:
  • Field Details

  • Constructor Details

    • EntityView

      public EntityView(@NonNull @NonNull org.springframework.ui.ModelMap model, @NonNull @NonNull org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
  • Method Details

    • getTemplate

      public String getTemplate()
    • setTemplate

      public void setTemplate(String template)
    • getAttribute

      public <V, Y extends V> Y getAttribute(String attributeName, Class<V> expectedType)
      Get an attribute from the model and coerce it to the expected type.
      Type Parameters:
      V - type the attribute value should have
      Y - return type specification for generics
      Parameters:
      attributeName - name of the attribute
      expectedType - type the attribute value should have
      Returns:
      value or null
    • getAttribute

      public Object getAttribute(String attributeName)
      Specified by:
      getAttribute in interface org.springframework.ui.Model
    • removeAttribute

      public <V, Y extends V> Y removeAttribute(String attributeName, Class<V> expectedType)
      Remove the attribute with the given name from the model and coerce the attribute value returned to the expected type.

      Note that the type coercing will only occur after the attribute has been removed!

      Type Parameters:
      V - type the attribute value should have
      Y - return type specification for generics
      Parameters:
      attributeName - name of the attribute
      expectedType - type the attribute value should have
      Returns:
      value or null
    • removeAttribute

      public Object removeAttribute(String attributeName)
    • setRedirectUrl

      public void setRedirectUrl(String redirectUrl)
      Set the redirect url, if the redirect url is not null, this will also disable rendering.
      Parameters:
      redirectUrl - to use
    • setResponseEntity

      public void setResponseEntity(org.springframework.http.ResponseEntity<?> responseEntity)
      Set a ResponseEntity that should be used for the view.. Short-hand for setCustomView(Object).
      Parameters:
      responseEntity - to return
    • getResponseEntity

      public <V> org.springframework.http.ResponseEntity<V> getResponseEntity()
      Get the response entity that will be used as view.
      Returns:
      null if not a response entity
    • isRedirect

      public boolean isRedirect()
      Returns:
      true if redirectUrl is set
    • isResponseEntity

      public boolean isResponseEntity()
      Returns:
      true if the view returns a ResponseEntity
    • isCustomView

      public boolean isCustomView()
      Returns:
      true if the view is neither a redirect, nor a view name; this method will also return true if the view is a response entity
    • shouldRender

      public boolean shouldRender()
      Returns:
      true if the view renders visual output
    • addAttribute

      public org.springframework.ui.Model addAttribute(String attributeName, Object attributeValue)
      Specified by:
      addAttribute in interface org.springframework.ui.Model
    • addAttribute

      public org.springframework.ui.Model addAttribute(Object attributeValue)
      Specified by:
      addAttribute in interface org.springframework.ui.Model
    • addAllAttributes

      public org.springframework.ui.Model addAllAttributes(Collection<?> attributeValues)
      Specified by:
      addAllAttributes in interface org.springframework.ui.Model
    • addAllAttributes

      public org.springframework.ui.Model addAllAttributes(Map<String,?> attributes)
      Specified by:
      addAllAttributes in interface org.springframework.ui.Model
    • mergeAttributes

      public org.springframework.ui.Model mergeAttributes(Map<String,?> attributes)
      Specified by:
      mergeAttributes in interface org.springframework.ui.Model
    • containsAttribute

      public boolean containsAttribute(String attributeName)
      Specified by:
      containsAttribute in interface org.springframework.ui.Model
    • asMap

      public Map<String,Object> asMap()
      Specified by:
      asMap in interface org.springframework.ui.Model
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getModel

      public org.springframework.ui.ModelMap getModel()
    • getRedirectAttributes

      public org.springframework.web.servlet.mvc.support.RedirectAttributes getRedirectAttributes()
    • getRedirectUrl

      public String getRedirectUrl()
    • getCustomView

      public Object getCustomView()
    • setCustomView

      public void setCustomView(Object customView)
    • setShouldRender

      public void setShouldRender(boolean shouldRender)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object