Class declaration.

### Callable classes

Since Ceylon 1.2 classes are not always directly invokable (if the class has constructors, but not a default constructor). Thus members of `ClassDeclaration` which depend on the class parameter list typically have optional type, but are refined on `ClassWithInitializerDeclaration` to be non-optional. The exceptions to this are `instantiate()` and `memberInstantiate()`, which throw exceptions.

### Usage sample for toplevel classes

Because some classes have type parameters, getting a model requires applying type arguments to the class declaration with `classApply()` in order to be able to instantiate that class. For example, here is how you would obtain a class model that you can instantiate from a toplevel class declaration:

    class Foo<T>(){
        string => "Hello, our T is: ``typeLiteral<T>()``";
    }

    void test(){
        // We need to apply the Integer closed type to the Foo declaration in order to get the Foo<Integer> closed type
        Class<Foo<Integer>,[]> classModel = `class Foo`.classApply<Foo<Integer>,[]>(`Integer`);
        // This will print: Hello, our T is: ceylon.language::Integer
        print(classModel());
    }

### Usage sample for member classes

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

    class Outer(){
        shared class Inner(){
            string => "Hello";
        }
    }

    void test(){
        // apply the containing closed type `Outer` to the member class declaration `Outer.Inner`
        MemberClass<Outer,Outer.Inner,[]> memberClassModel = `class Outer.Inner`.memberClassApply<Outer,Outer.Inner,[]>(`Outer`);
        // We now have a MemberClass, which needs to be applied to a containing instance in order to become an
        // invokable class model:
        Class<Outer.Inner,[]> boundMemberClassModel = memberClassModel(Outer());
        // This will print: Hello
        print(boundMemberClassModel());
    }

no type hierarchy

- `ClassDeclaration`
  - `ClassOrInterfaceDeclaration`
    - `GenericDeclaration`
    - `NestableDeclaration`
      - `AnnotatedDeclaration`
        - `Annotated`
        - `Declaration`
      - `TypedDeclaration`

- `ClassDeclaration` of
  - `ClassWithConstructorsDeclaration`
  - `ClassWithInitializerDeclaration`

Attributes
`abstract` | Source Code `shared formal Boolean abstract` True if the class has an abstract annotation.
`annotation` | Source Code `shared formal Boolean annotation` True if the current declaration is an annotation class or function. Since 1.2.0
`anonymous` | Source Code `shared formal Boolean anonymous` True if the class is an anonymous class, as is the case for the class of object value declarations.
`defaultConstructor` | Source Code `shared formal CallableConstructorDeclaration? defaultConstructor` A constructor declaration representing the class initializer (for a class with a parameter list) or the default constructor, or null if the class lacks both a parameter list and a default constructor. Since 1.2.0
`final` | Source Code `shared formal Boolean final` True if the class has a final annotation.
`objectValue` | Source Code `shared formal ValueDeclaration? objectValue` This anonymous class' object value declaration if this class is an anonymous class. `null` otherwise. Since 1.1.0
`parameterDeclarations` | Source Code `shared formal FunctionOrValueDeclaration[]? parameterDeclarations` The list of parameter declarations for this class. Returns `null` if the class lacks both a parameter list and a default constructor. Since 1.2.0
`serializable` | Source Code `shared formal Boolean serializable` True if the class is serializable class. Since 1.2.0

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`
Attributes inherited from: `ClassOrInterfaceDeclaration` `caseTypes`, `extendedType`, `isAlias`, `satisfiedTypes`
Attributes inherited from: `Declaration` `name`, `qualifiedName`
Attributes inherited from: `GenericDeclaration` `typeParameterDeclarations`
Attributes inherited from: `NestableDeclaration` `actual`, `container`, `containingModule`, `containingPackage`, `default`, `formal`, `shared`, `static`, `toplevel`
Attributes inherited from: `TypedDeclaration` `openType`

Methods
`annotatedConstructorDeclarations` | Source Code `shared formal ConstructorDeclaration[] annotatedConstructorDeclarations<Annotation>() given Annotation satisfies AnnotationType` Returns the list of constructors declared on this class that are annotated with the given `Annotation` type argument. This includes unshared constructors. Since 1.2.0
`classApply` | Source Code `shared formal Class<Type,Arguments> classApply<Type = Anything, Arguments = Nothing>(AppliedType<Anything>* typeArguments) given Arguments satisfies Anything[]` Applies the given closed type arguments to this toplevel class declaration in order to obtain a class model. See this code sample for an example on how to use this. Throws `IncompatibleTypeException` If the specified `Type` or `Arguments` type arguments are not compatible with the actual result. `TypeApplicationException` If the specified closed type argument values are not compatible with the actual result's type parameters.
`constructorDeclarations` | Source Code `shared formal ConstructorDeclaration[] constructorDeclarations()` Returns the list of constructors declared on this class. This includes unshared constructors. Since 1.2.0
`getConstructorDeclaration` | Source Code `shared formal <CallableConstructorDeclaration|ValueConstructorDeclaration>? getConstructorDeclaration(String name)` Looks up a constructor declaration directly declared on this class, by name. Returns `null` if no such constructor matches. This includes unshared constructors but not inherited constructors (since constructors are not members). Since 1.2.0
`getParameterDeclaration` | Source Code `shared formal FunctionOrValueDeclaration? getParameterDeclaration(String name)` Gets a parameter declaration by name. Returns `null` if this class lacks both a parameter list and a default constructor, or if no such parameter exists in the parameter list. Since 1.2.0
`instantiate` | Source Code `shared default Object instantiate(AppliedType<Anything>[] typeArguments = [], Anything* arguments)` Creates a new instance of this toplevel class, by applying the specified type arguments and value arguments. Parameters: `typeArguments = []` Throws `IncompatibleTypeException` If the specified type or value arguments are not compatible with this toplevel class, or if the class lacks both a parameter list and a default constructor.
`memberClassApply` | Source Code `shared formal MemberClass<Container,Type,Arguments> memberClassApply<Container = Nothing, Type = Anything, Arguments = Nothing>(AppliedType<Object> containerType, AppliedType<Anything>* typeArguments) given Arguments satisfies Anything[]` Applies the given closed container type and type arguments to this member class declaration in order to obtain a member class model. See this code sample for an example on how to use this. Throws `IncompatibleTypeException` If the specified `Container`, `Type` or `Arguments` 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.
`memberInstantiate` | Source Code `shared default Object memberInstantiate(Object container, AppliedType<Anything>[] typeArguments = [], Anything* arguments)` Creates a new instance of this member class, by applying the specified type arguments and value arguments. Parameters: `typeArguments = []` Throws `IncompatibleTypeException` If the specified container, type or value arguments are not compatible with this method, or if the class lacks both a parameter list and a default constructor.
`staticClassApply` | Source Code `shared formal Class<Type,Arguments> staticClassApply<Type = Anything, Arguments = Nothing>(AppliedType<Object> containerType, AppliedType<Anything>* typeArguments) given Arguments satisfies Anything[]` Applies the given closed type arguments to this `static` member class declaration in order to obtain a class model. Throws `IncompatibleTypeException` If the specified `Type` or `Arguments` type arguments are not compatible with the actual result. `TypeApplicationException` If the specified closed type argument values are not compatible with the actual result's type parameters.
`staticInstantiate` | Source Code `shared default Object staticInstantiate(AppliedType<Object> containerType, AppliedType<Anything>[] typeArguments = [], Anything* arguments)` Creates a new instance of this `static` member class, by applying the specified type arguments and value arguments. Parameters: `typeArguments = []`

Inherited Methods
Methods inherited from: `Object` `equals()`
Methods inherited from: `Annotated` `annotated()`
Methods inherited from: `AnnotatedDeclaration` `annotations()`
Methods inherited from: `ClassOrInterfaceDeclaration` `annotatedDeclaredMemberDeclarations()`, `annotatedMemberDeclarations()`, `apply()`, `declaredMemberDeclarations()`, `getDeclaredMemberDeclaration()`, `getMemberDeclaration()`, `memberApply()`, `memberDeclarations()`
Methods inherited from: `GenericDeclaration` `getTypeParameterDeclaration()`