Entity Builders

If Integration modelling is enabled, the SDK provides Builders for entities. These builders can be easily used to construct entities using the builder pattern which allow to write readable, understandable code to set up complex objects.

Namespace entity builders

  • Each namespace has its own entity builder grouping usually prefixed with the namespace acronym.

  • Namespace with prefix cards would get a CardsEntityBuilder class that can be injected and groups all the entity builders in that domain.

For example:

// Import Entity Builder of namespace prefixed by cc
import de.cards.sdk.domain.cc.facade;

// Declaring Entity Builder for namespace cards
@Autowired
protected CardsEntityBuilder cardsEntityBuilder;

// Using Entity Builder
AmexCard amexCard = cardsEntityBuilder.getAmexCard().build();

Integration entity builder

Besides Namespace entity builders, the SDK also provides an IntegrationEntityBuilder which groups all namespace entity builders of integration namespaces.

Tip:

You can inject the IntegrationEntityBuilder into your implementation code as shown below. Additionally, in the implementation of integration services, it is available automatically as entityBuilder, derived from the base class.

// Import IntegrationEntityBuilder
import de.cards.sdk.integration.facade.IntegrationEntityBuilder;

// Declare & Inject Integration Entity Builder
@Autowired
private IntegrationEntityBuilder integrationEntityBuilder;
      
// Use Integrationn Entity Builder to create an entity that was modelled in 
// integration namespace with prefix: cards
AmexCard amexCard = this.integrationEntityBuilder.getCards().getAmexCard().build();

// use default entityBuilder derived from the base class
// Create a visa card entity that exists in an integration namespace prefixed by cards.
VisaCard visaCard = entityBuilder.getCards().getVisaCard().build();
Tip:

Please also see Domain entity builder.