classafPlastic::PlasticClassModel
sys::Obj afPlastic::PlasticClassModel
Models a Fantom class.
If not defined already, types are generated with a standard it-block ctor:
new make(|This|? f := null) { f?.call(this) }
All added fields and methods will be public. As you will never compile against the generated code, this should not be problematic.
- addCtor
PlasticCtorModel addCtor(Str ctorName, Str signature, Str body, Str? superCtor := null)
Add a ctor.
signature
does not include (brackets).body
does not include {braces}superCtor
is the entire expression,super.make(in)
- addFacet
PlasticFacetModel addFacet(Type type, Str:Str params := [:])
- addFacetClone
- addField
PlasticFieldModel addField(Type fieldType, Str fieldName, Str? getBody := null, Str? setBody := null)
Add a field.
getBody
andsetBody
are code blocks to be used in theget
andset
accessors.- addMethod
PlasticMethodModel addMethod(Type returnType, Str methodName, Str signature, Str body)
Add a method.
signature
does not include (brackets).body
does not include {braces}- className
const Str className
The name of the class.
- ctors
PlasticCtorModel[] ctors { private set }
- extend
Extends the given type; be it a class or a mixin.
If
type
is a class, it is set as the superclass, if it is a mixin, it is extended.If this model is const, then the given type must be const also.
The type must be public.
- facets
PlasticFacetModel[] facets { private set }
- fields
PlasticFieldModel[] fields { private set }
- hasField
Returns
true
if this model has a field with the given name.- isConst
const Bool isConst
Set to
true
if this class isconst
- make
new make(Str className, Bool isConst)
Creates a class model with the given name.
- methods
PlasticMethodModel[] methods { private set }
- mixins
Type[] mixins := Type[,] { private set }
A list of mixin types the model extends.
- overrideCtor
PlasticCtorModel overrideCtor(Method ctor, Str body)
Override a ctor The given ctor method must exist in a super class / mixin.
body
does not include {braces}- overrideField
PlasticFieldModel overrideField(Field field, Str? getBody := null, Str? setBody := null)
Override a field. The given field must exist in a super class / mixin.
getBody
andsetBody
are code blocks to be used in theget
andset
accessors.- overrideMethod
PlasticMethodModel overrideMethod(Method method, Str body)
Override a method. The given method must exist in a super class / mixin.
body
does not include {braces}- superClass
Type superClass := sys::Obj# { private set }
The superclass type.
- toFantomCode
Str toFantomCode()
Converts the model into Fantom source code.
All types are generated with a standard serialisation ctor:
new make(|This|? f := null) { f?.call(this) }
- usingPod
use
the given pod.- usingStr
use
the given Str, should not start with using.- usingType
This usingType(Type type, Str? usingAs := null)
use
the given type.- usings
PlasticUsingModel[] usings { private set }