default-immutables

Default styles for Immutables

License

License

Categories

Categories

Immutables Application Layer Libs Code Generators
GroupId

GroupId

com.mercateo
ArtifactId

ArtifactId

default-immutables
Last Version

Last Version

1.2.5
Release Date

Release Date

Type

Type

jar
Description

Description

default-immutables
Default styles for Immutables
Project URL

Project URL

https://github.com/Mercateo/default-immutables
Project Organization

Project Organization

Mercateo AG
Source Code Management

Source Code Management

https://github.com/Mercateo/default-immutables.git

Download default-immutables

How to add to project

<!-- https://jarcasting.com/artifacts/com.mercateo/default-immutables/ -->
<dependency>
    <groupId>com.mercateo</groupId>
    <artifactId>default-immutables</artifactId>
    <version>1.2.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.mercateo/default-immutables/
implementation 'com.mercateo:default-immutables:1.2.5'
// https://jarcasting.com/artifacts/com.mercateo/default-immutables/
implementation ("com.mercateo:default-immutables:1.2.5")
'com.mercateo:default-immutables:jar:1.2.5'
<dependency org="com.mercateo" name="default-immutables" rev="1.2.5">
  <artifact name="default-immutables" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.mercateo', module='default-immutables', version='1.2.5')
)
libraryDependencies += "com.mercateo" % "default-immutables" % "1.2.5"
[com.mercateo/default-immutables "1.2.5"]

Dependencies

compile (4)

Group / Artifact Type Version
org.immutables : value jar 2.7.1
org.immutables : value-annotations jar 2.7.1
org.immutables : encode jar 2.7.1
org.immutables.vavr : vavr-encodings jar 0.6.0

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.11.1

Project Modules

There are no modules declared in this project.

Build Status Coverage Status MavenCentral

com.mercateo:default-immutables

Default-Styles and Helper-Classes for common use cases of Immutables, a framework based on annotation processors to generate simple, safe and consistent value objects

Data class style

After defining an immutable with data class style

@Value.Immutable
@DataClass
public interface ExampleDataClass {
    String getName();

    int counter();

    static ImmutableExampleDataClass.Builder builder() {
        return ImmutableExampleDataClass.builder();
    }
}

there is a builder

    ExampleDataClass dataClass = ExampleDataClass.builder()
            .name("foo")
            .counter(123)
            .build();

which even has a copy function:

    ExampleDataClass otherDataClass = ExampleDataClass.builder()
            .from(dataClass)
            .name("bar")
            .build();

Value style

After defining an immutable with data class style

@Value.Immutable
@ValueStyle
public interface _ExampleValue {
    String getName();

    int counter();
}

there is a builder

    ExampleValue value = ExampleValue.builder()
            .name("foo")
            .counter(123)
            .build();

which has a copy function in the builder:

    ExampleValue otherValue = ExampleValue.builder()
            .from(value)
            .name("bar")
            .build();

or a with method

    ExampleValue anotherValue = value.withName("baz");

Tuple style

After defining an immutable with tuple style

@Value.Immutable
@TupleStyle
public interface ExampleTuple {
    String name();

    int count();

    static ImmutableExampleTuple of(String name, int count) {
        return ImmutableExampleTuple.of(name, count);
    }
}

there is a static constructor method

    ExampleTuple tuple = ExampleTuple.of("foo", 123);

Typed Objects

Typed "primitives" can be easily defined:

@Value.Immutable
@Wrapped
public abstract class _ExampleTypedString extends Wrapper<String> {}

and used:

    ExampleTypedString typedString = ExampleTypedString.of("foo");

value(), .hashCode(), .equals(<other>) and .toString() are already there.

com.mercateo
the procurement platform for your business

Versions

Version
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0