Class InjectValueErrorHandlingStrategy

    • Constructor Detail

      • InjectValueErrorHandlingStrategy

        public InjectValueErrorHandlingStrategy()
    • Method Detail

      • handleMissingValue

        public <T> T handleMissingValue​(String path,
                                        T defaultValue)
        This handler is invoked when a value cannot be resolved from a path. This happens when value is not present or null.
        Specified by:
        handleMissingValue in interface ErrorHandlingStrategy
        Type Parameters:
        T - Type of default Value
        Parameters:
        path - Path for which value was not found
        defaultValue - Default value to be returned if present
        Returns:
        defaultValue or exception depending on implementation
      • handleTypeMismatch

        public <T> T handleTypeMismatch​(String path,
                                        String expected,
                                        String actual,
                                        T defaultValue)
        This handler is invoked when there is type mismatch between value at path and that present in json.
        Specified by:
        handleTypeMismatch in interface ErrorHandlingStrategy
        Type Parameters:
        T - Type of defaultValue
        Parameters:
        path - Path for which value mismatch was detected
        expected - Expected type
        actual - Type found in provided json
        defaultValue - Default value to be returned in case of mismatch
        Returns:
        defaultValue or throws exception depending on implementation
      • handleIllegalEval

        public <T> T handleIllegalEval​(String message,
                                       T defaultValue)
        This handler is called in case there is some bug in the evaluation. This should never be raised faced in production. In case this happens it is a bug that should be reported.
        Specified by:
        handleIllegalEval in interface ErrorHandlingStrategy
        Type Parameters:
        T - Type of defaultValue
        Parameters:
        message - Custom message provided at assertion site
        defaultValue - Default value to be returned if this state is faced
        Returns:
        defaultValue or throws exception depending on implementation