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.
signaturedoes not include (brackets).bodydoes not include {braces}superCtoris 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.
getBodyandsetBodyare code blocks to be used in thegetandsetaccessors.- addMethod
PlasticMethodModel addMethod(Type returnType, Str methodName, Str signature, Str body)Add a method.
signaturedoes not include (brackets).bodydoes not include {braces}- className
const Str classNameThe name of the class.
- ctors
PlasticCtorModel[] ctors { private set }- extend
Extends the given type; be it a class or a mixin.
If
typeis 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
trueif this model has a field with the given name.- isConst
const Bool isConstSet to
trueif 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.
bodydoes 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.
getBodyandsetBodyare code blocks to be used in thegetandsetaccessors.- overrideMethod
PlasticMethodModel overrideMethod(Method method, Str body)Override a method. The given method must exist in a super class / mixin.
bodydoes 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
usethe given pod.- usingStr
usethe given Str, should not start with using.- usingType
This usingType(Type type, Str? usingAs := null)usethe given type.- usings
PlasticUsingModel[] usings { private set }