Class StringFactory

java.lang.Object
is.codion.framework.domain.entity.StringFactory

public final class StringFactory extends Object
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);
 }

 void testStringFactory() {
		Entity department = createDepartment();// With name: Accounting
 		Entity employee = createEmployee(department);// 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.