An interface declaration.
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); } }
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 | |
interfaceApply | Source 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
|
memberInterfaceApply | Source 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
|
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Annotated |
Methods inherited from: AnnotatedDeclaration |
Methods inherited from: ClassOrInterfaceDeclaration |
Methods inherited from: GenericDeclaration |