Interface GeneralProblems

All Superinterfaces:
ProblemFactory

public interface GeneralProblems extends ProblemFactory

General purpose problems that can appear in many parts of the system. These are an alternative to, and an eventual replacement for, problems coded up with StandardCodes.

  • Method Details

    • get

      static GeneralProblems get()
    • required

      static Problem required(String name, Class<?> typeOfThing)

      Produces error: 'name' typeOfThing was required but not found. This is a helper for when the required object doesn't actually exist yet.

    • required

      Problem required(Object thing)

      Produces error: 'thing' was required but not found

    • objectAlreadyExists

      Problem objectAlreadyExists(String id, Class<?> identifiedClass)

      Produces an error for when a user to tries to add an object with an id that is already used, e.g. adding a function with the same id twice.

    • noSuchObjectExists

      Problem noSuchObjectExists(String id, Class<?> clazz)

      Produces an error for when a user has referenced an object by its id and it doesn't exist

    • noSuchObjectExistsDidYouMean

      Problem noSuchObjectExistsDidYouMean(String id, Class<? extends Identified> clazz, List<String> similarIds)
    • failedResourceLookedUp

      Problem failedResourceLookedUp(String id, Resource resource, Class<?> failedClass)

      Produces an error for when a user has referenced and object by its id, but it has errors associated with it that mean it can't be used. It's expected that the caller of this constructor append the failures to this problem

    • failedObjectLookedUp

      Problem failedObjectLookedUp(String id, Class<?> failedClass)

      Version of failedResourceLookedUp(String, Resource, Class) where no resource (or the unknown resource) is available.

    • badResource

      Problem badResource(Class<?> expectedType, URI location)
      Returns:
      a problem suitable for wrapping other problems caused by trying to build a type of thing from a resource
    • notAnOption

      Problem notAnOption(String value, Object context, List<?> possibleOptions)

      '' is not a valid option for . Available options are: '.

    • notAnOptionSimilarTo

      Problem notAnOptionSimilarTo(String value, List<?> similarOptions)

      When value is not a valid option. The similar options may be subset of those available. 'value' is not a valid option. Did you mean one of: '

    • operationNotSupported

      Problem operationNotSupported(String operation, Class clazz)

      For when an operation is called despite not being supported.

      Parameters:
      operation - up-supported operation that was called
      clazz - the class that does not support the operation
    • notAnOption

      static <T extends Enum<?>> Problem notAnOption(String value, Class<T> enumClass)

      Convenience version of notAnOption(String, Object, List) for enums. Useful when a user supplied string doesn't match any of the values from the given enum

    • couldNotConvert

      Problem couldNotConvert(String parameterName, Class<?> parameterType, String invalidValue)

      A problem suitable for wrapping a more specific parameter binding error

    • failedToBuild

      Problem failedToBuild(Object thing)

      Failed to construct from the input provided

    • failedToValidate

      Problem failedToValidate(Class<? extends Identified> kindOfThing, String id, Resource resource)

      When an Identified object has failed validation

    • badListLength

      Problem badListLength(String expectedNumber, int actual)

      A list was provided, but it was expected to contain a certain number of elements

    • deprecated

      Problem deprecated(Object thing, Object replacement)

      When thing has be deprecated but is used.

      Parameters:
      thing - that has been deprecated
      replacement - the replacement for thing
    • multipleProblems

      Problem multipleProblems()

      Useful non-specific method to group a bunch of problems when there's no specific parent issue. Use Problems.toSingleProblem(List) instead of this method. FYI We could avoid this kind of nonsense if we had a ProblemList type that abstracted over this, a bit like a NodeList in some xml libs

    • precisionLoss

      Problem precisionLoss(Number from, Number to)
    • valueOutOfRange

      <T extends Comparable<?>> Problem valueOutOfRange(Object affected, T value, com.google.common.collect.Range<T> range)

      A given value was outside of an expected range.

      Could be a parameter or a function argument or any other place that user input is accepted, so this problem lives here rather than in one of the specific factories

    • badValue

      Problem badValue(Object value, Object thing, Object constraint)

      "Value '<value-provided>' for <named-thing> is invalid, it must be <some-constraint>" E.g. "Value '0' for 'num-event-sets' parameter is invalid, it must be > 0"

    • badArity

      Problem badArity(Class<?> arityThing, Object parent, com.google.common.collect.Range<Integer> expected, int actual)
    • nameAlreadyUsedBy

      Problem nameAlreadyUsedBy(String id, Object usedBy, Class<?> thing)