I started with this basic abstract class for Geometry:
@Serializable
abstract const class Geometry {
const Str type
new make( Str type, |This| f ) {
this.type = type
f(this)
}
}
Then I extended this abstract class to model a Point:
const class GeoPoint : Geometry {
const Decimal[] coordinates
new make( |This| f ) : super( "Point", f ) { }
Decimal? longitude() { coordinates.size >= 1 ? coordinates[ 0 ] : null }
Decimal? latitude() { coordinates.size >= 2 ? coordinates[ 1 ] : null }
Decimal? altitude() { coordinates.size >= 3 ? coordinates[ 2 ] : null }
}
This compiles Ok and works fine in a simple scenario, but if I try to use via IoC, I get this error message:
[err] [afBedSheet] afIoc::IocErr - Field myPod::GeoPoint.coordinates was not set by ctor sys::Void make(|sys::This->sys::Void| f)
Causes:
afIoc::IocErr - Field myPod::GeoPoint.coordinates was not set by ctor sys::Void make(|sys::This->sys::Void| f)
sys::FieldNotSetErr - myPod::GeoPoint.coordinates
IoC Operation Trace:
[ 1] Autobuilding 'GeoPoint'
[ 2] Creating 'GeoPoint' via ctor autobuild
[ 3] Instantiating myPod::GeoPoint via Void make(|This->Void| f)...
Stack Trace:
afIoc::IocErr : Field myPod::GeoPoint.coordinates was not set by ctor sys::Void make(|sys::This->sys::Void| f)
I presume it is because the constructor has another parameter, apart from |This| f
. Is there a better way to write the Geology and GeoPoint classes, please?