An interface declaration.

Usage sample for toplevel interfaces

Because some interfaces have type parameters, getting a model requires applying type arguments to the interface declaration with interfaceApply() in order to be able to get a closed type. For example, here is how you would obtain an interface model from a toplevel interface declaration:

interface Foo<T> satisfies List<T> {
}

void test(){
    // We need to apply the Integer closed type to the Foo declaration in order to get the Foo<Integer> closed type
    Interface<Foo<Integer>> interfaceModel = `interface Foo`.interfaceApply<Foo<Integer>>(`Integer`);
    // This will print: ceylon.language::List<ceylon.language::Integer>
    for(satisfiedType in interfaceModel.satisfiedTypes){
        print(satisfiedType);
    }
}

Usage sample for member interfaces

For member interfaces it is a bit longer, because member interfaces need to be applied not only their type arguments but also the containing type, so you should use memberInterfaceApply() and start by giving the containing closed type:

class Outer(){
    shared interface Inner<T> satisfies List<T> {
    }
}

void test(){
    // apply the containing closed type `Outer` to the member class declaration `Outer.Inner`
    MemberInterface<Outer,Outer.Inner<Integer>> memberInterfaceModel = `interface Outer.Inner`.memberInterfaceApply<Outer,Outer.Inner<Integer>>(`Outer`, `Integer`);
    // This will print: ceylon.language::List<ceylon.language::Integer>
    for(satisfiedType in memberInterfaceModel.satisfiedTypes){
        print(satisfiedType);
    }
}

no type hierarchy

no subtypes hierarchy

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: ClassOrInterfaceDeclaration
Attributes inherited from: Declaration
Attributes inherited from: GenericDeclaration
Attributes inherited from: NestableDeclaration
Attributes inherited from: TypedDeclaration
Methods
interfaceApplySource Codeshared formal Interface<Type> interfaceApply<Type = Anything>(AppliedType<Anything>* typeArguments)

Applies the given closed type arguments to this toplevel interface declaration in order to obtain an interface model. See this code sample for an example on how to use this.

Throws
memberInterfaceApplySource Codeshared formal MemberInterface<Container,Type> memberInterfaceApply<Container = Nothing, Type = Anything>(AppliedType<Object> containerType, AppliedType<Anything>* typeArguments)

Applies the given closed container type and type arguments to this member interface declaration in order to obtain a member interface model. See this code sample for an example on how to use this.

Throws
  • IncompatibleTypeException

    If the specified Container or Type type arguments are not compatible with the actual result.

  • TypeApplicationException

    If the specified closed container type or type argument values are not compatible with the actual result's container type or type parameters.

Inherited Methods
Methods inherited from: Object
Methods inherited from: Annotated
Methods inherited from: AnnotatedDeclaration
Methods inherited from: ClassOrInterfaceDeclaration
Methods inherited from: GenericDeclaration