Package org.apache.commons.beanutils2.converters

# Class DimensionConverter

java.lang.Object
org.apache.commons.beanutils2.converters.AbstractConverter<Dimension>
org.apache.commons.beanutils2.converters.DimensionConverter

All Implemented Interfaces:
  `Converter<Dimension>`

public class DimensionConverter extends AbstractConverter<Dimension>
`Converter` implementation that handles conversion to and from `Dimension`.

Accepts a single `Integer` value, or two `Integer` values separated by the character `x`.

The dimensions must consist of non-negative `Integer` values only.

Since:
  2.0.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DimensionConverter()`
  Construct a `Dimension` Converter that throws a `ConversionException` if an error occurs.
  `DimensionConverter(Dimension defaultValue)`
  Constructs a `Converter` that will return the specified default value if a conversion error occurs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected <T> T`
  `convertToType(Class<T> type, Object value)`
  Converts the input object into an output object of the specified type.
  `protected Class<Dimension>`
  `getDefaultType()`
  Gets the default type this `Converter` handles.

  ### Methods inherited from class org.apache.commons.beanutils2.converters.AbstractConverter

  `conversionException, convert, convertArray, convertToString, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toLowerCase, toString, toString, toTrim`

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

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

- ## Constructor Details

  - ### DimensionConverter

    public DimensionConverter()
    Construct a `Dimension` Converter that throws a `ConversionException` if an error occurs.

  - ### DimensionConverter

    public DimensionConverter(Dimension defaultValue)
    Constructs a `Converter` that will return the specified default value if a conversion error occurs.
    Parameters:
      `defaultValue` - The default value to be returned if the value to be converted is missing or an error occurs converting the value.

- ## Method Details

  - ### convertToType

    protected <T> T convertToType(Class<T> type, Object value) throws Throwable
    Converts the input object into an output object of the specified type.
    Specified by:
      `convertToType` in class `AbstractConverter<Dimension>`
    Type Parameters:
      `T` - Target type of the conversion.
    Parameters:
      `type` - Data type to which this value should be converted.
      `value` - String property value to convert.
    Returns:
      A `Dimension` which represents the configuration property value.
    Throws:
      `NullPointerException` - If the value is null.
      `NumberFormatException` - If the `Dimension` width or height is bigger than `Integer.MAX_VALUE`.
      `Throwable` - if an error occurs converting to the specified type

  - ### getDefaultType

    protected Class<Dimension> getDefaultType()
    Gets the default type this `Converter` handles.
    Specified by:
      `getDefaultType` in class `AbstractConverter<Dimension>`
    Returns:
      The default type this `Converter` handles.
    Since:
      2.0.0