Interface ResolvedBookmark
Links a Bookmark
to a BookmarkResolver
in order to access the useful data.
A ResolvedBookmark
indicates that a BookmarkResolver
has said that the bookmark looks like it
can be accessed by a particular resolver. However, the BookmarkResolver
may already have spotted errors
with the bookmark that prevent it being opened, such as a missing or invalid option. These sorts of errors
should be returned by the validate()
method.
A ResolvedBookmark
can also return any failure information when the actual data was opened, in addition to
any validation Problem
s. These should be returned alongside the validation errors in the problems
associated with the getData(Class)
method.
It is expected that implementations will not attempt to reopen a bookmark with each call to access the data, so implementations are free to memoize any validation errors or constructed objects.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ResolvedBookmark
from
(@NonNull Object object, @NonNull List<Problem> dataProblems, @NonNull List<Problem> validationProblems) static ResolvedBookmark
Useful testing constructor to return a pre-constructed Object with a fake Bookmark objectstatic ResolvedBookmark
Useful testing constructor to return a pre-constructed Object with a fake Bookmark objectdefault <T> ResultOrProblems<T>
Class<?>
default String
getId()
Shortcut forgetBookmark()
andBookmark.getId()
<T> Optional<ResultOrProblems<T>>
Performs a conditional cast of the resolved thing, even if there are validation issues that stopped the data from being accessed Ifvalidate()
returned errors, then this method should return an empty result with an error saying there were validation errors stopping the data from being accessedReturns the RiskScape type that represents this data when extracted from a project and added in to a pipeline or expression as a scalar value.default boolean
default boolean
static ResolvedBookmark
stub
(@NonNull Bookmark bookmark, @NonNull Object object, @NonNull List<Problem> dataProblems, @NonNull List<Problem> validationProblems) Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.validate()
static ResolvedBookmark
withId
(@NonNull String bookmarkId, @NonNull Object object, @NonNull List<Problem> dataProblems, @NonNull List<Problem> validationProblems) Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.static ResolvedBookmark
Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.
-
Method Details
-
from
Useful testing constructor to return a pre-constructed Object with a fake Bookmark object
-
from
Useful testing constructor to return a pre-constructed Object with a fake Bookmark object
- Parameters:
dataProblems
- to return with the data (not validation errors)
-
from
-
withId
Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.
-
withId
static ResolvedBookmark withId(@NonNull @NonNull String bookmarkId, @NonNull @NonNull Object object, @NonNull @NonNull List<Problem> dataProblems, @NonNull @NonNull List<Problem> validationProblems) Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.
-
stub
static ResolvedBookmark stub(@NonNull @NonNull Bookmark bookmark, @NonNull @NonNull Object object, @NonNull @NonNull List<Problem> dataProblems, @NonNull @NonNull List<Problem> validationProblems) Useful testing constructor to return a pre-constructed Object with a fake Bookmark object that has the desired bookmarkId.
-
getId
Shortcut for
getBookmark()
andBookmark.getId()
- Returns:
- the id of the
Bookmark
-
getBookmark
Bookmark getBookmark()- Returns:
- the Bookmark that has been resolved
-
getData
- Returns:
- the underlying data in the required type, or empty with an error if the data isn't of that type
the result may contain errors that were encountered when trying to open the data with the given options
which might be further to those that were encountered during validation.
If
validate()
returned errors, then this method should return an empty result with an error saying there were validation errors stopping the data from being accessed
-
getIfType
Performs a conditional cast of the resolved thing, even if there are validation issues that stopped the data from being accessed If
validate()
returned errors, then this method should return an empty result with an error saying there were validation errors stopping the data from being accessed- Returns:
Optional.empty()
if the wrong type, or an optional of the required type.
-
getDataType
Class<?> getDataType()- Returns:
- the type of the resolved thing, regardless of whether it was successfully built or not.
-
isType
- Returns:
- true if the resolved thing is of the given type
-
validate
-
getScalarType
Type getScalarType()Returns the RiskScape type that represents this data when extracted from a project and added in to a pipeline or expression as a scalar value.
It is referred to as the scalar type to make it clear it's not the same as the
Type
of the data contained within it, e.g. theStruct
type of the relation (non-scalar) vsRelationType
that represents the relation itself (scalar). -
hasValidationErrors
default boolean hasValidationErrors()- Returns:
- true if there are problems returned from validation that are errors (or worse)
-