Class ProblemPlaceholder

java.lang.Object
nz.org.riskscape.engine.problem.ProblemPlaceholder
All Implemented Interfaces:
Identified

public class ProblemPlaceholder extends Object implements Identified

A convenient placeholder when constructing a Problem's args. We try to pass whole objects to the Problem's args - this leads to consistency in displaying/translating and makes messages more generic and reusable (see ObjectRenderer where we display objects in a user-friendly way). ProblemPlaceholder allows us to code the same Problems/messages regardless of whether we have an instance of the affected object or not. In many cases we will have hit an error before we've been able to create the object. E.g. ProblemPlaceholder('foo', Step.class) will be displayed to the user as "'foo' step", the same as if we had an actual Step object.

  • Constructor Details

    • ProblemPlaceholder

      public ProblemPlaceholder(String id, Class<?> wrappedClass)
  • Method Details

    • getIdentifiedClass

      public Class<? extends Identified> getIdentifiedClass()
      Specified by:
      getIdentifiedClass in interface Identified
      Returns:
      the class that implements the Identified interface - this should be the API class, and not the implementation class. For example the jython function would return IdentifiedFunction from here, not JythonFunction. The default implementation should be fine for most uses, apart from proxying.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static ProblemPlaceholder of(Class<?> contextClass, String name)

      Creates a placeholder object when there is none available, e.g. the problem occurred trying to create the thing of interest.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Specified by:
      getId in interface Identified
      Returns:
      id
    • getWrappedClass

      public Class<?> getWrappedClass()