Questions tagged [immutables-library]

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

99 questions
2
votes
1 answer

MapStruct does not detect setters in builder

I am building a simple REST service using spring. I separated my entities from DTOs and I made the DTOs immutable using Immutables. I needed mapping between DTOs and DAOs, so I chose MapStruct. The Mapper is not able to detect the setters I have…
djpanda
  • 835
  • 10
  • 20
2
votes
0 answers

How do I edit child collections in a copy of a Java `Immutables` object?

Given a @Value.Immutable-annotated class that contains a collection of immutable objects, what is the most elegant way to create a new copy, where the child objects are modified? For example, given a company with employees, if I want to set all…
Shteinitz
  • 37
  • 2
  • 5
2
votes
2 answers

Android: Dagger 2 interferes with Immutables?

Getting a really strange issue; hopefully you guys can help. I have been using Immutables library in my android project since a long time and had no issues. The auto-generated files for Immutable objects are located in (as example)…
Bonton255
  • 2,231
  • 3
  • 28
  • 44
2
votes
1 answer

Immutables class containing list does not throw exception when built without list

I have a class that I expect to throw an exception if it is attempted to be built without either name or stuff being specified in the builder. This happens if I don't set "name", but not if I don't set "stuff". @Value.Immutable public abstract class…
TheClassic
  • 974
  • 6
  • 20
2
votes
1 answer

Cannot partially deserialize JSON into Immutables object with spring boot

I have a JSON file that I read via restTemplate and want to store only certain fields in to my object. The call is successfull but my object does not contain the informations from the JSON. This is the file and I am only interested in the…
Gregsen
  • 471
  • 1
  • 5
  • 15
2
votes
1 answer

Issue with deserialization in dropwizard , cannot convert ImmutableList to string list

I am using dropwizard 1.1.0 with java 8 features. I am also using Immutables package. I am facing a deserialization issue when trying to convert list of profit centres (string list) from JSON to java equivalent. Error Can not find a deserializer…
serah
  • 2,057
  • 7
  • 36
  • 56
2
votes
1 answer

Why immutable null is discouraged?

I'm currently using Immutable library for generating JSON object from my web application. Looking at this chapter, the first line says: The use of nullable attributes is discouraged. So my question is: 1) why? what's wrong with a null object? 2)…
Fabrizio Stellato
  • 1,727
  • 21
  • 52
2
votes
1 answer

intelliJ IDEA support for immutables with sbt

When using the java immutables library with IDEA and sbt, compilation and running code works fine, but the editor will give "Cannot resolve symbol ..." and "Cannot resolve method ..." errors when using the generated classes. Following the…
kag0
  • 5,624
  • 7
  • 34
  • 67
2
votes
3 answers

Mutable items in Immutable

When we create immutable classes using the Immutable objects library, how can we handle mutable members (e.g. j.u.Date)? NOTE: this is not about the java Date class and totally related to the Immutable Objects java library which will generate some…
TmTron
  • 17,012
  • 10
  • 94
  • 142
2
votes
1 answer

java org.immutables library: all duplicate insertion in map

I'm using the java immutables library. @Value.Immutable public interface Foo { Map getBar(); } ImmutableFoo.builder().putBar(1, "asdf").putBar(1, "ghjk").build() causes a duplicate key error. Is there any way to avoid…
lf215
  • 1,185
  • 7
  • 41
  • 83
2
votes
1 answer

How to use Jackson PropertyNamingStrategy with Immutables library

I am using https://immutables.github.io/ library with Jackson. I want my class to be Jackson-serializable. I would like to use custom PropertyNamingStrategy (configured for com.fasterxml.jackson.databind.ObjectMapper using …
Bartosz Bilicki
  • 12,599
  • 13
  • 71
  • 113
1
vote
1 answer

Make all fields in Java Immutable Nullable

@Immutable @Modifiable public interface Record { String id(); String fName(); String lName(); String mName(); } All the fields in Record can be Nullable. One way for me to make these fields Nullable is to add @Nullable…
Adi
  • 387
  • 3
  • 6
  • 14
1
vote
0 answers

Immutables Library Does Not Require Collection Attributes To Be Set

I recently started using the Immutables library, and I'm puzzled by the following behavior: Given the following abstract value type @Value.Immutable public abstract class Foo { public abstract String bar(); public abstract List
Isaac Kleinman
  • 3,994
  • 3
  • 31
  • 35
1
vote
1 answer

Immutables custom create and of methods

I am changing a library that uses Immutables. In the class that I change I just added a new variable and in the generated classes I see different signatures in the create and of methods. ImmutableMyClass.of(previous variables ..., int…
mcvkr
  • 3,209
  • 6
  • 38
  • 63
1
vote
0 answers

Using Immutables with Thymeleaf multiple select for an Enum List

I've started using Thymeleaf recently, and generally been getting on pretty well. However I'm trying to use a multiple select to populate a list of Enums that are wrapped up in an immutable. I refactored it and it works using a POJO: public enum…
trickster
  • 75
  • 1
  • 9