Package nz.org.riskscape.engine.typeset
Interface TypeRules
- All Known Implementing Classes:
TypeSet
public interface TypeRules
Minimal TypeSet
interface for use when only testing of types is required/allowed.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Print some debug info to the TypeRules logger - this should be decorated with some extra context that helps put a particular rule checks logging more easily interpretedfindEquivalenceCoercer
(Type sourceType, Type targetType) Search through the list ofEquivalenceRule
s and find the first one that can safely coerce a value from the source type to the target type.default boolean
isAssignable
(Type sourceType, Type targetType) testVariance
(Type sourceType, Type targetType) Search through the list ofVarianceRule
s to determine whether a value of sourceType can be assigned to a receiver of targetType
-
Method Details
-
findEquivalenceCoercer
Search through the list of
EquivalenceRule
s and find the first one that can safely coerce a value from the source type to the target type. This will return an object that will allow the source type to be safely converted to the target type.- Parameters:
sourceType
- the type of the value that is being assigned to something. typetargetType
- the receiving type- Returns:
- a
Coercer
, or empty if none could be found.
-
testVariance
Search through the list of
VarianceRule
s to determine whether a value of sourceType can be assigned to a receiver of targetType- Parameters:
sourceType
- the type of the value that is being assigned to something.targetType
- the receiving type- Returns:
- a determined variance calculation, or
Variance.UNKNOWN
if it couldn't be determined. You should assume invariance if unknown is returned.
-
isAssignable
- Returns:
- true if values of
sourceType
can be assigned to values oftargetType
. Note that this test is not commutable, i.e. isAssignable(lhs, rhs) is not equivalent to isAssignable(rhs, lhs).
-
debug
Print some debug info to the TypeRules logger - this should be decorated with some extra context that helps put a particular rule checks logging more easily interpreted
-