java.lang.Object
is.codion.framework.domain.entity.StringFactory
Factory class for building functions for String representations of
Entity
instances.
interface Department {
EntityType TYPE = DOMAIN.entityType("employees.department");
Column<Integer> ID = TYPE.integerColumn("id");
Column<String> NAME = TYPE.stringColumn("name");
}
interface Employee {
EntityType TYPE = DOMAIN.entityType("employees.employee");
Column<String> NAME = TYPE.stringColumn("name");
Column<Integer> DEPARTMENT_ID = TYPE.integerColumn("department_id");
ForeignKey DEPARTMENT_FK = TYPE.foreignKey("department_fk", DEPARTMENT_ID, Department.ID);
}
Entity department = ...// With name: Accounting
Entity employee = ...// With name: John and the above department
Function<Entity, String> stringFactory =
StringFactory.builder()
.text("Name=")
.value(Employee.NAME)
.text(", Department="')
.value(Employee.DEPARTMENT_FK, Department.NAME)
.text("'");
System.out.println(stringFactory.apply(employee));
Outputs the following String:
Name=John, Department='Accounting'
given the entities above.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A Builder for a string function, which provides toString() values for entities. -
Method Summary
-
Method Details
-
builder
- Returns:
- a
StringFactory.Builder
instance for configuring a string factoryFunction
for entities.
-