-
Notifications
You must be signed in to change notification settings - Fork 0
Item
G-Art edited this page Dec 24, 2020
·
3 revisions
Item is a declaration of a Java class that represents a table with relations as a java object
Item has the following parameters:
Parameter | values | description |
---|---|---|
extend | (Declared item name) | (Optional) Using to extend existing type same as java extends. By default extends Generic item declared in core module |
table | true or false | (Optional) By default "true" if true type will get dedicated table, if "false" all specified fields will store in closest parent item with dedicated table. |
abstract | true or false | (Optional) By default "false" affect only java class and make item abstract if it's required. |
enhance | module name | (Optional) Used to add additional attributes to already exist Item example: (enhance: 'core') just need to define module name that declares desired item. |
Example:
Example {
description = "Example item"
attributes {
exampleField(String) {
description = "Example field"
}
}
}
ExampleExtend(extend: Example, table: false, abstract: true) {
description = "Example item extend"
attributes {
exampleFieldNew(String) {
description = "Example field new"
}
}
}
Example(enhance: 'example') {
attributes {
additionalExampleField(String) {
description = "Example field"
}
}
}
Result:
public class ExampleItem extends GenericItem {
public static final String ITEM_TYPE = "Example";
public static final String EXAMPLE_FIELD = "exampleField";
public ExampleItem() {
super();
}
public ExampleItem(ItemContext ctx) {
super(ctx);
}
/**
* Example field
*/
public String getExampleField(){
return getItemContext().getValue(EXAMPLE_FIELD);
}
/**
* Example field
*/
public void setExampleField(String exampleField){
getItemContext().setValue(EXAMPLE_FIELD, exampleField);
}
}
public abstract class ExampleExtendItem extends ExampleItem {
public static final String ITEM_TYPE = "ExampleExtend";
public static final String EXAMPLE_FIELD_NEW = "exampleFieldNew";
public ExampleExtendItem() {
super();
}
public ExampleExtendItem(ItemContext ctx) {
super(ctx);
}
/**
* Example field new
*/
public String getExampleFieldNew(){
return getItemContext().getValue(EXAMPLE_FIELD_NEW);
}
/**
* Example field new
*/
public void setExampleFieldNew(String exampleFieldNew){
getItemContext().setValue(EXAMPLE_FIELD_NEW, exampleFieldNew);
}
}
Declaration item attribute must be inside attributes block.
Example:
attributes {
exampleField(String) {
description = "Example field"
}
}