Class OptionsBuilder<T,​R extends OptionOwner>

  • Type Parameters:
    T - the type to create Options from
    R - the owner of the options
    Direct Known Subclasses:
    SelectionBuilder

    public class OptionsBuilder<T,​R extends OptionOwner>
    extends Object
    A builder for Options, providing a fluent API.
    Author:
    Matthias Müller
    • Constructor Detail

      • OptionsBuilder

        public OptionsBuilder​(R owner)
        Create a new builder, using the given owner.
        Parameters:
        owner - the owner of the options
      • OptionsBuilder

        protected OptionsBuilder()
    • Method Detail

      • setOwner

        protected void setOwner​(R owner)
        Sets the owner for this builder
        Parameters:
        owner - the owner
      • options

        public OptionsBuilder<T,​R> options​(Iterable<T> elements)
        Sets the elements to build options from
        Parameters:
        elements - the elements
        Returns:
        this builder
      • select

        public OptionsBuilder<T,​R> select​(T selected)
        Selects a single elements, i.e. the created option will be selected.
        Parameters:
        selected - the selected element
        Returns:
        this builder
        See Also:
        selector, select(Collection)
      • disable

        public OptionsBuilder<T,​R> disable​(Collection<T> disabled)
        Disables a single element, i.e. the created option will be disabled
        Parameters:
        disabled - the disabled element
        Returns:
        this builder
        See Also:
        disable(Object)
      • disable

        public OptionsBuilder<T,​R> disable​(T disabled)
        Disables some elements, i.e. the created options will be disabled
        Parameters:
        disabled - the disabled elements
        Returns:
        this builder
        See Also:
        disable(Collection)
      • defaultOption

        public OptionsBuilder<T,​R> defaultOption​(String name,
                                                       String value)
        Adds an option at the very first position
        Parameters:
        name - the name for the option to be added
        value - the value for the option to be added
        Returns:
        this builder
      • build

        public R build()
        Creates the options and adds the to the owner
        Returns:
        the owner the options