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

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

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

"""An attribute model represents the model of a Ceylon attribute that you can read and inspect.
   
   An attribute is a member value: it is declared on classes or interfaces.
   
   This is both a [[ValueModel]] and a [[Member]]: you can invoke it with an instance value
   to bind it to that instance and obtain a [[Value]]:
   
       class Outer(){
           shared String foo = "Hello";
       }
       
       void test(){
           Attribute attribute = `Outer.foo`;
           Value boundAttribute = attribute(Outer());
           // This will print: Hello
           print(boundAttribute.get());
       }
 """
shared sealed interface Attribute
        satisfies ValueModel & Member> {
    
    "The declaration model of this attribute, 
     which is necessarily a [[ValueDeclaration]]."
    shared actual formal ValueDeclaration declaration;
    
    "Binds this attribute to the given container instance. The instance type is checked at runtime."
    throws(`class StorageException`,
        "If this attribute is not stored at runtime, for example if it is neither shared nor captured.")
    shared actual formal Value bind(Anything container);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy