Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

It's called Fluent Pattern, and as already mentioned, it enables chaining. You can see it demonstrated in the Composite pattern in Apex Design Patterns.

It's worth reading the excellent answers on Why Would I Not Enable Chaining?Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();

It's called Fluent Pattern, and as already mentioned, it enables chaining. You can see it demonstrated in the Composite pattern in Apex Design Patterns.

It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();

It's called Fluent Pattern, and as already mentioned, it enables chaining. You can see it demonstrated in the Composite pattern in Apex Design Patterns.

It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();
added 141 characters in body
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

It's called Fluent Pattern, and as already mentioned, it enables chaining. You can see it demonstrated in the Composite pattern in Apex Design Patterns.

It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();

It's called Fluent Pattern, and as already mentioned, it enables chaining. It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();

It's called Fluent Pattern, and as already mentioned, it enables chaining. You can see it demonstrated in the Composite pattern in Apex Design Patterns.

It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

It's called Fluent Pattern, and as already mentioned, it enables chaining. It's worth reading the excellent answers on Why Would I Not Enable Chaining? for a deeper dive into the impact, but it's incredibly useful for building data. For example, I use it in my SObjectFactory library to simplify specification of multiple fields.

List<Opportunity> records = new SObjectBuilder(Opportunity.sObjectType)
    .put (Opportunity.AccountId, SObjectFactory.provideGenericParent(Account.sObjectType))
    .put(Opportunity.CloseDate, Date.today())
    .count (Limits.getLimitQueries() + 1)
    .create().getRecords();