Contracts-TS Documentation
    Preparing search index...

    Interface Contract<T>

    A Contract defines a deliverable type by name and type. Note: This is a final class and should not be extended!

    interface Contract<T> {
        get guarded(): boolean;
        get name(): string;
        get replaceable(): boolean;
        get typeName(): string;
        cast(value: unknown): OptionalType<T>;
    }

    Type Parameters

    • T

      the type of deliverable for this Contract

    Index

    Accessors

    • get guarded(): boolean

      When guarded is true the Contract throws exception if deliverable is null or undefined The default is true.

      Returns boolean

    • get replaceable(): boolean

      When replaceable a new binding can replace in an existing one The default is false

      Returns boolean

      true if replaceable

    • get typeName(): string

      Note: Do not rely on this being a java class name Note: The actual class is never exposed and is by design.

      Returns string

      the type of deliverable for this contract.

    Methods

    • Casts the given object to the return type for this Contract This is used to make sure the value is a checked value and does not sneak passed during erasure

      Parameters

      • value: unknown

        the value to cast

      Returns OptionalType<T>

      the checked value. Note: null is possible. The Promisor is allowed to return null

      ContractException if the value can't be cast to the return type.