Class IteratorViewElementBuilderContext<ITEM>

All Implemented Interfaces:
ReadableAttributes, WritableAttributes, LocalizedTextResolver, IteratorItemStats<ITEM>, ViewElementBuilderContext, org.springframework.core.AttributeAccessor

public class IteratorViewElementBuilderContext<ITEM> extends DefaultViewElementBuilderContext implements ViewElementBuilderContext, IteratorItemStats<ITEM>
Wrapping ViewElementBuilderContext that is used by a ViewElementGenerator and provides access to the item being generated and the possible iteration context.

This context optionally takes a parent context. All attributes from the parent context will be inherited and can be masked or replaced in the iterator context. This context does not automatically register default attributes (see DefaultViewElementBuilderContext.registerMissingDefaultAttributes(ViewElementBuilderContext)).

Author:
Arne Vandamme
  • Constructor Details

    • IteratorViewElementBuilderContext

      public IteratorViewElementBuilderContext(@NonNull @NonNull IteratorItemStats<ITEM> itemStats)
  • Method Details

    • hasPrevious

      public boolean hasPrevious()
      Specified by:
      hasPrevious in interface IteratorItemStats<ITEM>
      Returns:
      True if previous items have been generated.
    • isFirst

      public boolean isFirst()
      Specified by:
      isFirst in interface IteratorItemStats<ITEM>
      Returns:
      True if this item is the first one being generated.
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface IteratorItemStats<ITEM>
      Returns:
      True if another item needs generating.
    • isLast

      public boolean isLast()
      Specified by:
      isLast in interface IteratorItemStats<ITEM>
      Returns:
      True if this item is the last one being generated.
    • getItem

      public ITEM getItem()
      Specified by:
      getItem in interface IteratorItemStats<ITEM>
      Returns:
      the curren iteration item
    • getIndex

      public int getIndex()
      Specified by:
      getIndex in interface IteratorItemStats<ITEM>
      Returns:
      Index of the item in the collection.
    • getParentContext

      public ViewElementBuilderContext getParentContext()
      Returns:
      parent context that attributes are inherited from
    • setParentContext

      public void setParentContext(ViewElementBuilderContext parentContext)
      Set the parent context that this iteration context wraps around. All attributes from the parent context will be available in the iteration scope.
      Parameters:
      parentContext - to inherit the attributes from