Questions tagged [immutables-library]

Use this tag for questions relating to the Immutables Library for Java.

99 questions
3
votes
1 answer

Immutables Criteria Syntax Error In JDK 11 Module

I have a project that I'm trying to play around with the Immutables Criteria: https://immutables.github.io/criteria.html I added the following to my pom.xml: org.immutables
umhelp
  • 175
  • 8
3
votes
1 answer

Force Java Immutables to generate toString() for Throwable classes

Is it possible to force Java Immutables annotation processing library to generate toString method for an abstract class which already inherits non-default toString() method? For example: @Value.Immutables public abstract class MyRuntimeException…
DaTval
  • 316
  • 1
  • 6
  • 14
3
votes
1 answer

Immutables lib adds @Nullable to equals() method

I have a very simple class and using Immutables library. The auto-generated code defines equals method like so: @Override public boolean equals(@Nullable Object another) { The @Nullable annotation causes the following FindBugs…
Bonton255
  • 2,231
  • 3
  • 28
  • 44
3
votes
0 answers

Immutables-library generates the same immutable class twice

When using the immutables.io annotation processor in a multi-module android app, the build fails, when a package-info.java file is used. I've managed to build a minimal test-project on GitHub to reproduce the issue: ImmutablesPackageInfoIssue The…
TmTron
  • 17,012
  • 10
  • 94
  • 142
3
votes
1 answer

Enforce specific Map implementation in Immutables

I am using Immutables Java library, how can I enforce a specific map implementation, without having to use a specific reference? @Immutable public interface ConfigIF { Map getOptions(); } If I use the above code the concrete Map…
Andrea Bergonzo
  • 3,983
  • 4
  • 19
  • 31
3
votes
0 answers

immutables: should we use the Interface or ImmutableValueObject

The question is about using the immutables java library. In their documentation they seem to use the ImmutableValueObject only to construct the instance and then in the code they use the ValueObject (interface or abstract base class) like…
TmTron
  • 17,012
  • 10
  • 94
  • 142
3
votes
1 answer

Carry forward annotation from interface to generated java class when using Immutables

I am using Immutables (http://immutables.org) in my Java interface to generate builders and immutable object. I have created a custom method level annotation called @Primary (denoting which attribute is primary field) that I have used to annotate…
serah
  • 2,057
  • 7
  • 36
  • 56
3
votes
1 answer

How to use Immutable library with Interface

I want to make immutables my DTO object. For that, I want to use http://immutables.github.io/. I have the next legacy hierarchy: public interface Interface1 extends Serializable{ public void method1(); } public interface Interface2 extends…
Sergio Rodríguez Calvo
  • 1,183
  • 2
  • 16
  • 32
2
votes
1 answer

Jackson serialization of immutable value class with optional fields

I am using Immutables library (https://immutables.github.io). My class looks as follows: package com.abc.myservice.data.models; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import…
bappak
  • 865
  • 8
  • 23
2
votes
1 answer

Immutable Valid annotations not running

I'm trying to use immutable library https://immutables.github.io/ and validate the fields using javax.validation but the annotations are just ignored when the class is generated. Even on unit testing it just doesn't throw any error. import…
John
  • 1,697
  • 4
  • 27
  • 53
2
votes
0 answers

How to bind properties with immutables.org library?

I know it's possible to have some values bound from a properties file in Spring, like so: class Foo { @Value("${some.config.property}") String value; ... } On the current project I'm working for they are keen to use the immutables…
Edito
  • 3,030
  • 13
  • 35
  • 67
2
votes
1 answer

Jackson won't deserialize on org.immutable interface

Following scenario. Little SpringBoot application with the following classes: FooDto: import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.LinkedList; import…
Pwnstar
  • 2,333
  • 2
  • 29
  • 52
2
votes
2 answers

Optional with @NotBlank giving error while @Size not giving for a Immutable Class using Javax validation

I have following POJO: import java.util.Optional; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.immutables.value.Value; @Value.Immutable public interface ABC { Optional<@NotBlank String>…
hatellla
  • 4,796
  • 8
  • 49
  • 101
2
votes
0 answers

Forcing an Immutable interface to implement a Functional interface

I'm working with Java Immutable library http://immutables.github.io/ I have 3 Immutable classes, so basically 3 classes with a bunch of params. For each of these classes, we have a unique key. So, I decided to define an interface like this: public…
Nitesh
  • 193
  • 1
  • 2
  • 17
2
votes
1 answer

Selectively @JsonIgnore Immutables accessor methods, ONLY during serialization or deserialization using Jackson

This is definitely not a duplicate of Only using @JsonIgnore during serialization, but not deserialization. The problem is the same but in the context of Immutables. When a model(DTO/DAO) is decorated as an Immutable, I am not able to selectively…
djpanda
  • 835
  • 10
  • 20