Skip to content

Initials

Rajab Davudov edited this page Apr 5, 2019 · 3 revisions

Initials

It is possible to define initial values for tags. You need to use initial property inside @BioTag.

@BioObj
public class Car extends BioObject {
	@BioTag(type="String")
	public static final String PRODUCER = "producer" ;
	@BioTag(type="Integer", initial="2007")
	public static final String YEAR_OF_PRODUCTION = "year_of_production" ;
}

Initial value will be added if newly created Bio Object doesn't contain that tag. Sometimes you can provide source Bio Object to be used in creation. In this case initials are checked after Bio Object created and all tags in source are added.

Initial arrays also can be defined as CSV.

@BioObj
public class Car extends BioObject {
	@BioTag(type="String")
	public static final String PRODUCER = "producer" ;
	@BioTag(type="Integer", initial="2007")
	public static final String YEAR_OF_PRODUCTION = "year_of_production" ;
	@BioTag(type="Integer", isArray=true, initial="1,2,3,4,5")
	public static final String GEARS = "gears" ;
}

Initial Expressions

It is also possible to define initial expression. Initial expressions are evaluated using data inside Bio Object. Since Bio Objects are maps, you can put any information and use it in initial expressions. All unnecessary tags can be removed later by trimming.

```java
@BioObj
public class Car extends BioObject {
	@BioTag(type="String")
	public static final String PRODUCER = "producer" ;
	@BioTag(type="Integer", initial="2007")
	public static final String YEAR_OF_PRODUCTION = "year_of_production" ;
	@BioTag(type="Integer", isArray=true, initial="1,2,3,4,5")
	public static final String GEARS = "gears" ;
	@BioTag(type="Boolean", expression="year_of_production > 2016")
	public static final String IS_NEW_CAR = "is_new_car" ;
}

Initial expressions are defined using expression property inside annotation.

Note that initials are processed before initial expressions. For example year_of_production is initial and also it is used in is_new_car tag's initial expression.

Clone this wiki locally