-
Notifications
You must be signed in to change notification settings - Fork 1
Composition
Rajab Davudov edited this page Apr 7, 2019
·
6 revisions
Bio Object can be composed by other Bio Objects. You have to use type()
properties from @BioObj
annotation. type()
is by default class name but can be altered.
In order to compose we need to speficy tag by setting type
property type of inner Bio Object as following:
@BioObj(code=1, name="car", type="Car")
public class Car extends BioObject {
@BioTag(type="String")
public static final String PRODUCER = "producer" ;
@BioTag(type="String")
public static final String MODEL = "model" ;
@BioTag(type="Integer", initial="2019")
public static final String YEAR_OF_PRODUCTION = "year_of_production" ;
@BioTag(type="Engine")
public static final String ENGINE = "engine" ;
}
Here Engine
is a type of different Bio Object as below.
@BioObj(code=2, name="engine", type="Engine")
public class Engine extends BioObject {
@BioTag(type="Integer", initial="3200")
public static final String CAPACITY = "capacity" ;
@BioTag(type="Integer", initial="250")
public static final String HORSE_POWER = "horse_power" ;
@BioTag(type="Integer", initial="6")
public static final String NUMBER_OF_CYLINDERS = "number_of_cylinders" ;
}
Here if we have changed type="Engine"
to type="CarEngine"
then we would also modify tag definition in Car
and set correct type. But practically it is more than fine to leave type()
untouched and use class names as types.
@BioObj(code=1, name="car", type="Car")
public class Car extends BioObject {
@BioTag(type="CarEngine")
public static final String ENGINE = "engine" ;
}
Also a Bio Object can have an array of Bio Objects as following:
@BioObj
public class Plane extends BioObject {
@BioTag(type="Integer", initial="2019")
public static final String YEAR_OF_PRODUCTION = "year_of_production" ;
@BioTag(type="Engine", isArray=true)
public static final String ENGINES = "engines" ;
}