org.immutables:builder

2.11.0-beta2last stable release 3 weeks ago
Complexity Score
High
Open Issues
N/A
Dependent Projects
24

License

  • Apache-2.0
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Yespatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Readme

Read full documentation at http://immutables.org

Modern usage style, aka “sandwich”

// Define abstract value type using interface, abstract class or annotation
@Value.Immutable
public interface ValueObject extends WithValueObject {
  // WithValueObject is not yet generated, We extend With* to inherit `with*` method signatures
  String name();
  List<Integer> counts();
  Optional<String> description();

  class Builder extends ImmutableValueObject.Builder {}
  // ImmutableValueObject.Builder will be generated and
  // our builder will inherit and reexport methods as its own.
  // Static nested Builder will inherit all the public method
  // signatures of ImmutableValueObject.Builder
} 

// Use generated immutable implementation and builder
ValueObject v =
    new ValueObject.Builder()
        .name("Nameless")
        .description("present")
        .addCounts(1)
        .addCounts(2)
        .build();

v = v.withName("Doe");

//fetch values via accessors
List<Integer> counts = v.counts();
Optional<String> description = v.description();

ImmutableValueObject then would not be used outside generated type. See about this and other generation styles here

See releases tab for release history. Archived changelog for earlier releases.

Dependencies

No runtime dependency information found for this package.

CVE IssuesActive
0
Scorecards Score
4.50
Test Coverage
No Data
Follows Semver
No
Github Stars
3,474
Dependenciestotal
5
DependenciesOutdated
0
DependenciesDeprecated
0
Threat Modelling
No Data
Repo Audits
No Data

Learn how to distribute org.immutables:builder in your own private Maven registry

mvn install org.immutables:builder
Processing...
Done

134 Releases