Class AbstractListSelectControl.ConverterInfoModelValueRepresentationStrategy<VV>

java.lang.Object
io.guise.framework.component.AbstractListSelectControl.ConverterInfoModelValueRepresentationStrategy<VV>
Type Parameters:
VV - The type of value the strategy is to represent.
All Implemented Interfaces:
ListSelectControl.ValueRepresentationStrategy<VV>
Direct Known Subclasses:
AbstractListSelectControl.DefaultValueRepresentationStrategy
Enclosing class:
AbstractListSelectControl<V>

public static class AbstractListSelectControl.ConverterInfoModelValueRepresentationStrategy<VV> extends Object implements ListSelectControl.ValueRepresentationStrategy<VV>
A list select value representation strategy that creates a component by converting the value to a info model. The specified component class must have a constructor that takes a single InfoModel as an argument.
Author:
Garret Wilson
  • Constructor Details

    • ConverterInfoModelValueRepresentationStrategy

      public ConverterInfoModelValueRepresentationStrategy(Class<VV> valueClass, Class<? extends Component> componentClass)
      Value class constructor with a default converter. This implementation uses a DefaultStringLiteralConverter.
      Parameters:
      valueClass - The class indicating the type of value to convert.
      componentClass - The class of component to create.
      Throws:
      NullPointerException - if the given value class and/or component class is null.
      IllegalArgumentException - if the given component class does not have a constructor with a single InfoModel constructor.
    • ConverterInfoModelValueRepresentationStrategy

      public ConverterInfoModelValueRepresentationStrategy(Class<? extends Component> componentClass, Converter<VV,String> converter)
      Converter constructor.
      Parameters:
      converter - The converter to use for displaying the value as a string.
      componentClass - The class of component to create.
      Throws:
      NullPointerException - if the given converter is null.
      IllegalArgumentException - if the given component class does not have a constructor with a single InfoModel constructor.
  • Method Details

    • getConverter

      public Converter<VV,String> getConverter()
      Returns:
      The converter to use for displaying the value as a string.
    • createComponent

      public Component createComponent(ListSelectModel<VV> model, VV value, int index, boolean selected, boolean focused)
      Creates a component for the given list value. This implementation constructs a component from a info model that converts the value using the saved converter.
      Specified by:
      createComponent in interface ListSelectControl.ValueRepresentationStrategy<VV>
      Parameters:
      model - The model containing the value.
      value - The value for which a component should be created.
      index - The index of the value within the list, or -1 if the value is not in the list (e.g. for representing no selection).
      selected - true if the value is selected.
      focused - true if the value has the focus.
      Returns:
      A new component to represent the given value.
      See Also: