Registering an ENUM as an entity
EntityModule supports registration of enums as EntityConfiguration
.
When creating an EntityConfiguration
for an enum, a basic EntityModel
will get built and all enum properties will be configurable.
Registering enums as entity is mainly useful for configuration of display properties in related entity views.
Example registering an enum as entity
// Enum class
public enum Country
{
BE( "Belgium" ),
UK( "United Kingdom" ),
NL( "Netherlands" );
private String name;
Country( String name ) {
this.name = name;
}
public String getName() {
return name;
}
}
// Create the EntityConfiguration
@Override
public void configure( EntitiesConfigurationBuilder entities ) {
entities.create().entityType( Country.class, true ).label( "name" );
}
Labels
The labels for enum properties can be set using message codes.