org.springframework.shell.converters

## Class StaticFieldConverterImpl

- java.lang.Object
- - org.springframework.shell.converters.StaticFieldConverterImpl

- All Implemented Interfaces:
    StaticFieldConverter, Converter<Object>

      @Component
      public class StaticFieldConverterImpl
      extends Object
      implements StaticFieldConverter

  A simple `Converter` for those classes which provide public static fields to represent possible textual values.
  Since:
    1.0

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.shell.core.Converter

      `TAB_COMPLETION_COUNT_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StaticFieldConverterImpl()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Class<?> clazz)`
    `Object` | `convertFromText(String value, Class<?> requiredType, String optionContext)` Converts from the given String value to type T
    `boolean` | `getAllPossibleValues(List<Completion> completions, Class<?> requiredType, String existingData, String optionContext, MethodTarget target)` Populates the given list with the possible completions
    `void` | `remove(Class<?> clazz)`
    `boolean` | `supports(Class<?> requiredType, String optionContext)` Indicates whether this converter supports the given type in the given option context

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StaticFieldConverterImpl

          public StaticFieldConverterImpl()

  - ### Method Detail

    - #### add

          public void add(Class<?> clazz)

      Specified by:
        `add` in interface `StaticFieldConverter`

    - #### remove

          public void remove(Class<?> clazz)

      Specified by:
        `remove` in interface `StaticFieldConverter`

    - #### convertFromText

          public Object convertFromText(String value,
                               Class<?> requiredType,
                               String optionContext)

      Description copied from interface: `Converter`
      Converts from the given String value to type T
      Specified by:
        `convertFromText` in interface `Converter<Object>`
      Parameters:
        `value` - the value to convert
        `requiredType` - the type being converted to; can't be `null`
        `optionContext` - a non-`null` string that customises the behaviour of this converter for a given `CliOption` of a given `CliCommand`; the contents will have special meaning to this converter (e.g. be a comma-separated list of keywords known to this converter)
      Returns:
        see above

    - #### getAllPossibleValues

          public boolean getAllPossibleValues(List<Completion> completions,
                                     Class<?> requiredType,
                                     String existingData,
                                     String optionContext,
                                     MethodTarget target)

      Description copied from interface: `Converter`
      Populates the given list with the possible completions
      Specified by:
        `getAllPossibleValues` in interface `Converter<Object>`
      Parameters:
        `completions` - the list to populate; can't be `null`
        `requiredType` - the type of parameter for which a string is being entered
        `existingData` - what the user has typed so far
        `optionContext` - a non-`null` string that customises the behaviour of this converter for a given `CliOption` of a given `CliCommand`; the contents will have special meaning to this converter (e.g. be a comma-separated list of keywords known to this converter)
      Returns:
        `true` if all the added completions are complete values, or `false` if the user can press TAB to add further information to some or all of them

    - #### supports

          public boolean supports(Class<?> requiredType,
                         String optionContext)

      Description copied from interface: `Converter`
      Indicates whether this converter supports the given type in the given option context
      Specified by:
        `supports` in interface `Converter<Object>`
      Parameters:
        `requiredType` - the type being checked
        `optionContext` - a non-`null` string that customises the behaviour of this converter for a given `CliOption` of a given `CliCommand`; the contents will have special meaning to this converter (e.g. be a comma-separated list of keywords known to this converter)
      Returns:
        see above