Use this tag for questions relating to the Immutables Library for Java.
Questions tagged [immutables-library]
99 questions
13
votes
2 answers
Turn off "builders" in MapStruct when using Immutables
How do I completely disable using "builders" in MapStruct? I don't want to use them at all as they are causing all kinds of issues for me.
I created the service file under META-INF (I would prefer a way to assign it to the mapping builder= but I…

KJQ
- 447
- 1
- 7
- 28
13
votes
2 answers
How to make GitHub's Immutables work in IntelliJ + Gradle
I use GitHub's Immutables library for Android development, and now I want to give it a try on the backend side as well.
In Android, all I need to to in order to use the library is this:
dependencies {
compile fileTree(dir: 'libs', include:…

Vasiliy
- 16,221
- 11
- 71
- 127
9
votes
1 answer
Immutables don't generate code with java 9 with modules
Using immutables-library works fine with java 9 until I add a module-info.java to the project, Immutables*.java will no longer be generated.
To the module-info I add 'requires value' as suggested by IntelliJ.
What am I missing, is it a…

Lars KJ
- 632
- 7
- 15
6
votes
1 answer
Immutable configuration of Spring boot
I'm trying to find a way to use the Immutables library to create data classes for holding the configuration of my Spring Boot application.
My data configuration class is:
@Value.Immutable
@JsonDeserialize(as = ImmutableAuthConfig.class)
public…

Henrik Aasted Sørensen
- 6,966
- 11
- 51
- 60
5
votes
1 answer
Unable to load annotation processor factory in vs code
I am trying to use the immutables library with vscode (and Gradle).
Steps I've taken:
Confirmed that the jar exists
Ensured that the GRADLE_USER_HOME variable exists (it didn't initially)
Set the "java.import.gradle.home" vscode setting…

William
- 166
- 4
- 15
5
votes
0 answers
Can I specify annotations to be added to Immutable generated classes?
I have some code using Immutables (https://immutables.github.io/) which generates a ImmutableEntity class with a method like:
public static ImmutableEntity of(EntityId id,
Locale language,
…

Nic Cottrell
- 9,401
- 7
- 53
- 76
4
votes
1 answer
How to read List of Strings in spring application.yml file into Immutables object?
Here's a sample application.yml file
myapp:
resource:
teststring: "string"
testlist:
- "apple"
- "banana"
Here's my immutables configuration class
import org.immutables.value.Value.Immutable;
import…

kane
- 5,465
- 6
- 44
- 72
4
votes
0 answers
How to disable warnings in generated code in Java gradle project
I would like to have a gradle project that generates no compiler warnings on any code that I write. I would also like to use the Immutables library to generate some of my classes. At the moment I have no found a way to disable warnings for generated…

simonsays
- 408
- 4
- 12
4
votes
1 answer
Immutables Autogenerated repository for MongoDB throws "Can't find a codec for interface" CodecConfigurationException
Problem Description.
This is a simplified version of the example that is currently in the immutables site.
So I have an item that I want to use with MongoDB.
@Value.Immutable
@Mongo.Repository("items")
public abstract class Item {
@Mongo.Id
…

Spyros K
- 2,480
- 1
- 20
- 37
4
votes
1 answer
Can not write a field name, expecting a value
When we switched from Jackson version 2.8.9 to 2.9.8 we ran into some trouble with serializing data in CBOR format. As it turns out the custom Jackson module we've been using is causing trouble in this newer version. These issues start at version…

Sander Koenders
- 176
- 1
- 1
- 10
4
votes
1 answer
Integrate Kotlin with generated Java Classes
We use an annotation processing framework (Immutables) to generate Java classes from interfaces.
Now I have to access these generated classes from a kotlin class. While in Java this works well, the Kotlin compiler cannot find them.
Here is the maven…

Marc von Renteln
- 1,229
- 15
- 34
4
votes
1 answer
Annotations passed strangely from the Immutables interface to the implementation
I'm using Immutables to generate the immutable for this interface:
import javax.validation.constraints.Size;
...
@Value.Immutable
public interface Entity {
@Size(max = 10) // removing this also works
String name();
}
But the generated…

archie_by
- 1,623
- 2
- 11
- 10
4
votes
2 answers
Should I use real objects or mocks in unit tests with Immutables?
If I have to test a service that uses a mutable entity I would build the smallest object that I need (a real one) and pass it to my service. Example:
User joe = new…

ddreian
- 1,766
- 5
- 21
- 29
3
votes
1 answer
Using Class with immutables
I'm giving the immutables.org library a try. What I need is to be able to specify a class, so I've defined
@Value.Immutable
public interface Value {
Class getType();
}
The builder generated by immutables does not accept…

tbeernot
- 2,473
- 4
- 24
- 31
3
votes
0 answers
Detect multiple classes with same fully qualified name
My Java project with multiple subprojects is using the Immutables library for value objects.
package foo.bar;
import org.immutables.value.Value;
public class MyContainerClass {
@Value.Immutable
public interface Baz {
String…

Björn Marschollek
- 9,899
- 9
- 40
- 66