All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.meta.model.ClassOrInterface.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
import ceylon.language.meta.declaration {
    ClassOrInterfaceDeclaration
}

import ceylon.language.meta.model {
    ClosedType = Type
}

"Model of a class or interface that you can inspect.
 
 The models of classes and interfaces are also closed types."
shared sealed interface ClassOrInterface 
    of ClassModel | InterfaceModel
    satisfies Model & Generic & ClosedType {
    
    "The declaration for this class or interface."
    shared formal actual ClassOrInterfaceDeclaration declaration;

    "The extended closed type for this class or interface. 
     Note that the [[Anything|ceylon.language::Anything]] type
     has no extended type since it is the top of the type hierarchy."
    shared formal ClassModel<>? extendedType;
    
    "The list of closed types that this class or interface satisfies."
    shared formal InterfaceModel<>[] satisfiedTypes;

    "The list of case values for this type. This omits any case type to 
     only contain case values."
    shared formal Type[] caseValues;

    // FIXME: move all these to Type
    // FIXME: introduce MemberClassOrInterface?
    // if I do that I have to give up the enumerated type of ClassModel | InterfaceModel here, so let's not do that for now,
    // since I don't quite see what we would gain

    "Gets a member class or interface by name. Returns `null` if not found.
     
     The [[Container]] type parameter acts as a selector for the container of the member:
     
     - If it is the current type or a subtype, and the attribute exists in this type, then the attribute
       of the current type is returned. For example, looking up 'unit' in [[Integer]] with [[Integer]] as [[Container]]
       will return [[Integer.unit]].
     - If it is a supertype of this type, and that supertype defines this attribyte, then that supertype's
       attribute is returned. For example, looking up 'hash' in [[Integer]] with [[Object]] as [[Container]] will return [[Object.hash]].
     - If it is a type that is disjoint from this type, the attribute will be looked up in the common supertype
       between that type and this type. For example, looking up 'hash' in [[Integer]] with [[String]] as [[Container]] 
       will return [[Object.hash]].
     - If the common supertype between this type and the [[Container]] type has no such member, `null` is returned.
     "
    throws(`class IncompatibleTypeException`, 
           "If the specified `Kind` type argument is not compatible with the actual result.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal Member? getClassOrInterface
            >
            (String name, ClosedType* types)
        given Kind satisfies ClassOrInterface;

    "Gets a member class or interface by name. Returns `null` if not found.
     
     The [[Container]] type parameter acts as a selector for the container of the member:
     
     - If it is the current type or a subtype, and the attribute exists in this type, then the attribute
       of the current type is returned. For example, looking up 'unit' in [[Integer]] with [[Integer]] as [[Container]]
       will return [[Integer.unit]].
     - If it is a supertype of this type, or a type that is disjoint from this type, an [[IncompatibleTypeException]] will
       be thrown.
     - If this type has no such member, `null` is returned.
     "
    throws(`class IncompatibleTypeException`, 
           "If the specified `Container` or `Kind` type arguments are not compatible with the actual result.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal Member? getDeclaredClassOrInterface
            >
            (String name, ClosedType* types)
        given Kind satisfies ClassOrInterface;

    "Gets a member class by name. Returns `null` if not found.
     
     See [[getClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Type` or `Arguments` type arguments are not compatible with the actual result, 
            or if the corresponding member is not a `MemberClass`.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal MemberClass? getClass
            
            (String name, ClosedType* types)
        given Arguments satisfies Anything[];

    "Gets a member class by name. Returns `null` if not found.
     
     See [[getDeclaredClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Container`, `Type` or `Arguments` type arguments are not compatible with the actual result, 
            or if the corresponding member is not a `MemberClass`.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal MemberClass? getDeclaredClass
            
            (String name, ClosedType* types)
        given Arguments satisfies Anything[];

    "Gets a member interface by name. Returns `null` if not found.
     
     See [[getClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Type` type argument is not compatible with the actual result, 
            or if the corresponding member is not a `MemberInterface`.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal MemberInterface? getInterface
            
            (String name, ClosedType* types);
    
    "Gets a member interface by name. Returns `null` if not found.
     
     See [[getDeclaredClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Container` or `Type` type arguments are not compatible with the actual result, 
            or if the corresponding member is not a `MemberInterface`.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal MemberInterface? getDeclaredInterface
            
            (String name, ClosedType* types);
    
    "Gets a method by name. Returns `null` if not found.
     
     See [[getClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Type` or `Arguments` type arguments are not compatible with the actual result.")
    throws(`class TypeApplicationException`, 
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal Method? getMethod
            
            (String name, ClosedType* types)
        given Arguments satisfies Anything[];

    "Gets a method by name. Returns `null` if not found.
     
     See [[getDeclaredClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Container`, `Type` or `Arguments` type arguments are not compatible with the actual result.")
    throws(`class TypeApplicationException`,
           "If the specified closed type argument values are not compatible with the actual result's type parameters.")
    shared formal Method? getDeclaredMethod
            
            (String name, ClosedType* types)
        given Arguments satisfies Anything[];
    
    "Gets an attribute by name. Returns `null` if not found.
     
     See [[getClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Get` or `Set` type arguments are not compatible with the actual result.")
    shared formal Attribute? getAttribute
            
            (String name);

    "Gets an attribute by name. Returns `null` if not found.
     
     See [[getDeclaredClassOrInterface]] for how the [[Container]] type parameter works."
    throws(`class IncompatibleTypeException`, 
           "If the specified `Container`, `Get` or `Set` type arguments are not compatible with the actual result.")
    shared formal Attribute? getDeclaredAttribute
            
            (String name);

    "Gets a list of attributes matching the given container and attribute type, annotated with all the
     specified annotations, which are directly declared on this type."
    shared formal Attribute[] getDeclaredAttributes
            
            (ClosedType* annotationTypes);

    "Gets a list of attributes matching the given container and attribute type, annotated with all the
     specified annotations, which are declared on this type or inherited."
    shared formal Attribute[] getAttributes
            
            (ClosedType* annotationTypes);

    "Gets a list of methods matching the given container, return and parameter types, annotated with all the
     specified annotations, which are directly declared on this type."
    shared formal Method[] getDeclaredMethods
            
            (ClosedType* annotationTypes)
        given Arguments satisfies Anything[];

    "Gets a list of methods matching the given container, return and parameter types, annotated with all the
     specified annotations, which are declared on this type or inherited."
    shared formal Method[] getMethods
            
            (ClosedType* annotationTypes)
            given Arguments satisfies Anything[];

    "Gets a list of member classes matching the given container, return and parameter types, annotated with all the
     specified annotations, which are directly declared on this type."
    shared formal MemberClass[] getDeclaredClasses
            
            (ClosedType* annotationTypes)
            given Arguments satisfies Anything[];
    
    "Returns the list of shared member classes on this class or interface
     and annotated with all the specified annotations. 
     This includes inherited member classes but not unshared member classes."
    shared formal MemberClass[] getClasses
            
            (ClosedType* annotationTypes)
                given Arguments satisfies Anything[];

    "Returns the list of member interfaces directly declared on this class or interface 
     and annotated with all the specified annotations.
     This includes unshared member interfaces but not inherited member interfaces."
    shared formal MemberInterface[] getDeclaredInterfaces
            
            (ClosedType* annotationTypes);
    
    "Returns the list of shared member interfaces on this class or interface
     and annotated with all the specified annotations. 
     This includes inherited member interfaces but not unshared member interfaces."
    shared formal MemberInterface[] getInterfaces
            
            (ClosedType* annotationTypes);
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy