Annotation processor to create immutable objects and builders. Feels like Guava's immutable collections but for regular value objects. JSON, Jackson, Gson, JAX-RS integrations included

Overview

Read full documentation at http://immutables.org

CI

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

  class Builder extends ImmutableValueObject.Builder {}
  // ImmutableValueObject.Builder will be generated and
  // our builder will inherit and reexport methods as it's own
}

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

v = v.withName("Doe");

License

   Copyright 2013-2018 Immutables Authors and Contributors

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Changelog

See changelog for release history.

Comments
  • Jackson w/ immutables deserializes 2 times

    Jackson w/ immutables deserializes 2 times

    @cowtowncoder

    So I noticed while playing around with immutables and jackson deserialization that when I have an entity like this:

    @Immutable
    @JsonSerialize(as = ImmutableEntity.class)
    @JsonDeserialize(as = ImmutableEntity.class)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public interface Entity {
    
        int MIN_LEN_ANOTHER_FIELD = 2;
        int MAX_LEN_ANOTHER_FIELD = 10;
    
        /**
         * @return The field
         */
        String field();
    
        /**
         * @return another field
         */
        @Size(min = MIN_LEN_ANOTHER_FIELD, max = MAX_LEN_ANOTHER_FIELD)
        String getAnotherField();
    }
    

    That the deserialization process gets called twice when trying to deserialize a string like this:

            String json
                    = "{\"field\":\"f\",\"anotherField\":\"a\"}";
            ImmutableEntity pe = mapper.readValue(json, ImmutableEntity.class);
    

    I noticed this because when I trying to apply a custom deserializer that I wasn't expecting a 2nd pass because it breaks my custom deserializers. The first pass changes the ObjectNode json graph while the 2nd pass breaks because of the first call which changes it.

    It seems like it's related to this part of the generated ImmutableEntity.java:

      @Deprecated
      @JsonCreator
      static ImmutableEntity fromJson(Json json) {
        ImmutableEntity.Builder builder = ImmutableEntity.builder();
        if (json.field != null) {
          builder.field(json.field);
        }
        if (json.anotherField != null) {
          builder.anotherField(json.anotherField);
        }
        return builder.build();
      }
    

    But I can't figure out why it's calling deserialize 2 times (it seems wrong).

    Is there a bug here and/or a workaround? I've tried this with 2.8.3 and 2.3.3 of jackson + 2.2.1 of immutables.

    bug enhancement 
    opened by brentryan 39
  • TypeAdapter loading performance

    TypeAdapter loading performance

    Did some performance analysis on loading generate type adapters using the ServiceLoader method and got some troubling results: screenshot 2015-12-16 11 45 42

    It seems like this method does not work well on android due to inefficiencies in reading service data from a JAR. I was hoping to ask for an enhancement to how type adapters are registered. Rather than using the service loader, would it be possible to instead generate a single class GeneratedTypeAdapters which would return the list of type adapters that were generated? This way we would have a single entry point for getting the adapters rather than having to remember to add each manually. Thank you kindly.

    question knowledgebase 
    opened by digitalbuddha 25
  • Code not generated in some projects

    Code not generated in some projects

    I'm having a really hard time tracking this down, but we have some projects, that have the correct imports, but are no longer generating the immutable classes. All was working in 2.1.15, but after upgrading to 2.2.8 the files are just not being created. I've experimented around, and things work with 2.2, but not 2.2.1. It's worth noting that the project I'm seeing this on is quite large.

    opened by ldriscoll 24
  • Support of jarjar'd Guava and GSON libraries

    Support of jarjar'd Guava and GSON libraries

    We are using jarjar'd libraries of Guava and GSON, since we have third party libraries that use older versions of them. Our versions have an additional package to encapsulate Guava and GSON properly (e.g. custom.com.google.common.collect).

    Is it possible to configure immutables to prefer these libraries instead of the original ones in our classpath? Would be great to set this as an annotation processor option (see SupportedOptions).

    Is there a workaround for now that I could use, e.g. using JarJar to migrate value-2.0.21?

    enhancement completed 
    opened by arouel 23
  • Allow null value in Maps

    Allow null value in Maps

    Currently builder methods for Map types have implementations that prevent both null keys and null values. These implementations are a variant on the following:

    public final Builder metadata(String key, Object value) {
      this.metadatas.put(
          Objects.requireNonNull(key, "metadatas key"),
          Objects.requireNonNull(value, "metadatas value"));
      return this;
    }
    

    I believe that null keys are fine to reject, but that null values should be allowed. null values are often used to indicate the "removal" of an entry when used within JSON payloads. Today, it's nearly impossible to handle the fact that some external actor is returning a JSON payload with null values.

    enhancement completed knowledgebase 
    opened by nebhale 22
  • adding javax.validation.constraints.NotEmpty annotaion producing errors in generated code

    adding javax.validation.constraints.NotEmpty annotaion producing errors in generated code

    Hi, there seems to have been some regression. I'm using immutables 2.5.5

    @Value.Immutable
    @BaseStyle
    public abstract class UserImmutable {
    
        @NotEmpty
        abstract String getUsername();
    
    }
    

    is resulting in

    /**
     * Immutable implementation of {@link UserImmutable}.
     * <p>
     * Use the builder to create immutable instances:
     * {@code User.builder()}.
     */
    @SuppressWarnings({"all"})
    @Generated({"Immutables.generator", "UserImmutable"})
    public final class User extends UserImmutable {
      private final java.lang.@NotEmpty String username;
    .
    .
    .
    /**
       * @return The value of the {@code username} attribute
       */
      @Override
      java.lang.@NotEmpty String getUsername() {
        return username;
      }
    .
    .
    .
    }
    

    java.lang. is being added into the generated field and method text. The import for the annotation is correctly generated. My BaseStyle is only to change the naming convention. I'm compiling using Maven, as directed in the docs.

    opened by mcgaw 21
  • Stand-alone Criteria API to query different data-sources (initial draft)

    Stand-alone Criteria API to query different data-sources (initial draft)

    First draft of Criteria API. Please don't merge it yet.

    Generate criteria class based on existing model and evaluate it using visitor pattern.

    Right now only reflection based evaluator is provided.

    Missing functionality / Remaining Questions :

    1. (sub-)Criteria on Iterables. Example
      user.friends.anyMatch(FriendCriteria.create().age().greaterThan(22));
      user.friends.noneMatch(FriendCriteria.create().age().greaterThan(22))
      user.friends.allMatch(FriendCriteria.create().age().greaterThan(22));
      
      // something similar for optionals
      
    2. Combining criterias (using ANDs / ORs)
    3. Nested criterias
    4. Projections
    5. Aggregations
    6. Comparison between fields: field1 = field2
    7. DSL is not restrictive enough.
      // one can write something like this
      criteria.or().or().or();
      criteria.age().greaterThan(111).or().or(); // or this
      
    8. How are we better / worse than QueryDSL ?
    9. Allow user to define (inject) custom (native) queries like geo spacial
    opened by asereda-gs 20
  • Annotations on fields

    Annotations on fields

    Like in #456 I ran into the issue that one can not annotate the generated fields/constructors. I tried to use the storIO annotation processor which needs its annotations set directly on the fields. A possible solution might be as @VaclavPokorny proposed @bkenned4 had a similar idea

    enhancement completed 
    opened by ysndr 19
  • Significant memory leak in version 2.9.0

    Significant memory leak in version 2.9.0

    When we try to upgrade from version 2.8.8 to version 2.9.0 our medium-sized multi-module Maven build fails with java.lang.OutOfMemoryError: Java heap space. Based on investigation using JFR/JMC and git bisect the issue appears to be introduced in these two commits:

    • 080040703de9ee9a6a842e783be66a3a21ff24bb (#1235).
    • 2b9a79ce359d852c5c697792fd3f9f17b3c8efeb (#1249).

    Some numbers:

    • After the first commit meta space usage increases from ~115MB to ~260MB, while heap memory usage increases from ~270MB to ~620MB.
    • After the second commit heap memory usage further increases to ~960MB.

    (I performed many runs. There is little variance in these runs; on the order of ~5-10MB. After the first commit the classical GC zig-zag/sawtooth pattern all but disappears, hinting at a classical memory leak. See also the screenshots at the bottom of this message.)

    JMC's Memory -> Live Objects view hints at the thread local state of StaticEnvironment being retained. Based on some subsequent debugging the following issues appear to contribute:

    • AbstractGenerator#init calls StaticEnvironment.preInit, but if AbstractGenerator#process is not subsequently called then StaticEnvironment#shutdown won't be invoked.
    • Although we don't fork, it appears that each invocation of the maven-compiler-plugin loads a new StaticEnvironment class, which means that for each invocation a new thread-local EnvironmentState is created.
    • These two things combined appear to cause a significant memory leak, (I think) especially due to the accumulation of ProcessingEnvironments.

    I don't yet see a quick fix. Unfortunately javax.annotation.processing.Processor does not provide a "cleanup" or "shutdown" method. The proper fix likely involves getting rid of all this static and thread-local state (as also hinted at here), but that seems like a large task...

    That said, as-is version 2.9.0 of Immutables appears to be unusable for us. The build on which I reproduced this has 52 pom.xml files with 90 maven-compiler-plugin invocations (compile and testCompile combined), but we also have a few much-larger builds with 250+ pom.xml files.


    Below three screenshots from JMC's JVM Internals -> Garbage Collections view. The first build uses e31f58d44612f2211679a07229a96d9ddf62aa7a (i.e. the parent of the first problematic commit), the second uses 080040703de9ee9a6a842e783be66a3a21ff24bb, while the third uses 2b9a79ce359d852c5c697792fd3f9f17b3c8efeb. Note the Heap Post GC and Metaspace graphs.

    immutables-run-1 immutables-run-2 immutables-run-3

    bug help wanted 
    opened by Stephan202 18
  • 2.8.9-ea-1 compilation error on Java 11

    2.8.9-ea-1 compilation error on Java 11

    This simplified definition:

    @Value.Style(jdkOnly = true)
    @Value.Immutable(copy = false)
    public interface ValidationErrorDetails extends ErrorDetails {
        @Value.Parameter
        List<ValidationErrorMessage> getValidationErrors();
    }
    

    Raises a compilation error:

    [ERROR] .../target/generated-sources/annotations/.../errors/ImmutableValidationErrorDetails.java:[37,33] method copyOf in interface java.util.List<E> cannot be applied to given types;
      required: java.util.Collection<? extends E>
      found: java.lang.Iterable<capture#1 of ? extends ...errors.ValidationErrorMessage>
      reason: cannot infer type-variable(s) E
        (argument mismatch; java.lang.Iterable<capture#1 of ? extends ...errors.ValidationErrorMessage> cannot be converted to java.util.Collection<? extends E>)
    
    bug 
    opened by SimY4 18
  • AllowNulls and SkipNulls attribute level annotations for collections

    AllowNulls and SkipNulls attribute level annotations for collections

    The functionality added by @elucash for #349 does not appear to be working for me.

    From head of master I run cd value-fixture/src/org/immutables/fixture/nullable && javac -cp value-2.3.2.jar NullableElements.java NullableUse.java SkipNulls.java

    The generated code includes null checks. For example

    public final Builder putBl(String key, int value) {
      this.bl.put(
          Objects.requireNonNull(key, "bl key"),
          Objects.requireNonNull(value, "bl value"));
      return this;
    }
    

    By stepping through, I find that $AnnotationMirrors.from is returning an empty List for the type arguments.

    I am using javac 1.8.0_102. Any ideas?

    bug enhancement docbug 
    opened by NeilRickards 18
  • Collection Attributes Not Required?

    Collection Attributes Not Required?

    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<String> baz();
    }
    

    attempting to build an object like so

    ImmutableFoo.builder()
        .baz(List.of("1", "2", "3"))
        .build()
    

    fails because

    some of required attributes are not set [bar]

    yet

    ImmutableFoo.builder()
        .bar("1, 2, 3")
        .build()
    

    is fine, and there is no objection that baz has not been set.

    I'm aware that the doc states that

    When building using builders, the contents of collection attributes can be left unspecified](https://immutables.github.io/immutable.html#array-collection-and-map-attributes

    but why do collection attributes receive different treatment?

    opened by Isaac-Kleinman 0
  • How to avoid cloning arrays?

    How to avoid cloning arrays?

    Hi,

    Is there a way to avid .clone() when creating value objects that contain []byte ? Example in generated class:

      private ByteNotification(String label, String message, byte[] array) {
        this.label = Objects.requireNonNull(label, "label");
        this.message = Objects.requireNonNull(message, "message");
      // how to avoid cloning here ???
        this.array = array.clone();
        this.byteArrSize = initShim.byteArrSize();
        this.hexRepr = initShim.hexRepr();
        this.initShim = null;
      }
    

    I am passing large byte[] around in multiple objects generated with immutables. I want to avoid all this unnecessary CPU and memory allocation...

    opened by PyAntony 2
  • Feature request: Support withUnaryOperator in encodings

    Feature request: Support withUnaryOperator in encodings

    https://github.com/immutables/immutables/issues/1408 works like a charm but if I'm not mistaken there is no encoding support for it yet. It would be useful to be able to extend encodings of https://github.com/immutables/immutables-vavr for example. UnaryOperator-methods using Vavr-classes are not currently generated at least when using Vavr-encodings.

    opened by ajkettun 0
  • Support @JsonValue use with mandatory attributes marked with @JsonIgnore

    Support @JsonValue use with mandatory attributes marked with @JsonIgnore

    I have a class that looks something like this:

    @Value.Immutable
    @JsonSerialize
    public interface Foo extends GetValue {
      
      @JsonIgnore
      int value(); 
    
      @JsonValue
      List<Object> jsonValue();  
    
      @Override
      default int getValue() {
        return value();
      }
    }
    

    I want to be able to have a mandatory attribute on my object that has nothing to do with the way it's serialized, and define its serialization by using the @JsonValue annotation on a different attribute.

    Currently, this results in a compiler error: Cannot generate proper @JsonCreator for @JsonValue, other mandatory attributes are present. Could this be supported?

    I understand it's a quick fix to mark the attribute as non-mandatory and checking that the attribute is present somewhere else in the code, but I feel this is a hack because this really is a mandatory attribute and should be checked as such in the generated builder.

    opened by cameronprater 0
  • Redundant null check for JDK maps in generated code

    Redundant null check for JDK maps in generated code

    bc4493a393e1bf4bc0243bc57a584a1b6d569bd9 introduces a redundant null check for JDK maps. I found this because Spotbugs complains abound loading a known null value. The generated code looks like the following example:

    if (v == null) Objects.requireNonNull(v, "value for key: " + k);
    

    Obviously, it makes no sense to call Objects.requireNonNull() on a value known to be null. The if (v == null) is new since the mentioned commit. I don't think this should be there. Without it the code looks fine to me.

    opened by saarmbruster 0
Releases(2.9.3)
  • 2.9.3(Dec 13, 2022)

    Maintenance release

    What's Changed

    • #1408 withUnaryOperator style flag/naming template by @elucash in https://github.com/immutables/immutables/pull/1409
    • Avoid invalidating Gson type adapter cache when creating Mongo Repository by @jmoghisi in https://github.com/immutables/immutables/pull/1406
    • fixing #1407 - Default value with explicit null should use default. by @SimY4 in https://github.com/immutables/immutables/pull/1410
    • Fix counts in WriteResult for upsert operation by @dparamoshkin in https://github.com/immutables/immutables/pull/1412

    New Contributors

    • @dparamoshkin made their first contribution in https://github.com/immutables/immutables/pull/1412
    • @chncaption made their first contribution in https://github.com/immutables/immutables/pull/1414

    Full Changelog: https://github.com/immutables/immutables/compare/2.9.2...2.9.3

    Source code(tar.gz)
    Source code(zip)
  • 2.9.2(Sep 8, 2022)

    Fixes (reverts to older routine) issue affecting custom immutable annotations and meta annotation discovery in some cases leading to a deadlock: processing never finishes

    Source code(tar.gz)
    Source code(zip)
  • 2.9.1r(Aug 21, 2022)

    (includes 2.9.0 release notes)

    This release now requires Java 8 or later. Fixed memory leak introduced in 2.9.0 Contains many miscellaneous fixes accumulated over many months

    Special thanks to @SimY4 who made Immutables compatible with JDK11 and JDK17 environments.

    What's Changed

    • Support for JDK 11 and 17 (@SimY4)
    • Criteria and Repository classes are now generated in Eclipse compiler (ECJ). #1175
    • Add caching to CriteriaContext to avoid class scanning on each instantiation. #1241
    • #1189: criteria-geode backend toLowerCase/toUpperCase add parentheses by @garrettlestingi in https://github.com/immutables/immutables/pull/1190
    • Added Bill of Materials (BoM) artifact by @joke in https://github.com/immutables/immutables/pull/1191
    • Fix SuppressWarnings by @arouel in https://github.com/immutables/immutables/pull/1208
    • Fix repository generation for custom generic types by @coreyjboyle in https://github.com/immutables/immutables/pull/1207
    • When modifiable has modifiable default field, Immutables produces syntactically invalid code. by @SimY4 in https://github.com/immutables/immutables/pull/1212
    • Fix addAll(Iterator) NPE by @dmivankov in https://github.com/immutables/immutables/pull/1221
    • Remove redundant equality checks in with... methods on enum members by @jbewing in https://github.com/immutables/immutables/pull/1226
    • Write META-INF/services files when annotation processing is over by @arouel in https://github.com/immutables/immutables/pull/1235
    • resolve auto-module-name generation by @realumhelp in https://github.com/immutables/immutables/pull/1224
    • Bean friendly modifiable from method return converted result. by @SimY4 in https://github.com/immutables/immutables/pull/1211
    • Truncate strings or values of type variables in toString method that are longer than a defined length by @arouel in https://github.com/immutables/immutables/pull/1185
    • Diagnostics for NPE in SourceOrdering by @stepancheg in https://github.com/immutables/immutables/pull/1123
    • SuppressedWarnings: if it's deprecated, also suppress forRemoval by @stevenschlansker in https://github.com/immutables/immutables/pull/1156
    • replace TravisCI with GitHub Actions CI by @sullis in https://github.com/immutables/immutables/pull/1244
    • Immutables to build on all JDKs 8+ by @SimY4 in https://github.com/immutables/immutables/pull/1247
    • Fix some previously broken extensions support. by @SimY4 in https://github.com/immutables/immutables/pull/1249
    • Issue/bug 1245 by @SimY4 in https://github.com/immutables/immutables/pull/1279
    • Added eclipse compiler to build matrix by @SimY4 in https://github.com/immutables/immutables/pull/1280
    • Support abstract classes declaring static interned instances of their own type by @Stephan202 in https://github.com/immutables/immutables/pull/1274
    • Update README.md by @aaylward in https://github.com/immutables/immutables/pull/1292
    • Fresh fixes by @elucash in https://github.com/immutables/immutables/pull/1306
    • Java 16 compat by @SimY4 in https://github.com/immutables/immutables/pull/1326
    • Java 17 compat. by @SimY4 in https://github.com/immutables/immutables/pull/1328
    • Forward Encoding method parameter annotations by @darichey in https://github.com/immutables/immutables/pull/1320
    • Final Java 17 support by @SimY4 in https://github.com/immutables/immutables/pull/1337
    • Add sample code to demonstrate getter usage by @wisecodecraft in https://github.com/immutables/immutables/pull/1343
    • Fix five flaky tests in value-fixture by @pthariensflame in https://github.com/immutables/immutables/pull/1350
    • Use Java 17 target on Java 17. by @SimY4 in https://github.com/immutables/immutables/pull/1340
    • fixtures with and without errorprone by @SimY4 in https://github.com/immutables/immutables/pull/1341
    • [annotate] Fix javadoc typos by @piomar123 in https://github.com/immutables/immutables/pull/1345
    • Emit compile error when using @Value annotations on records by @dhoepelman in https://github.com/immutables/immutables/pull/1347
    • No explicit opens by using Add Opens manifest entry. by @SimY4 in https://github.com/immutables/immutables/pull/1354
    • Add Opens follow up. by @SimY4 in https://github.com/immutables/immutables/pull/1356
    • #1360 Prepend synthetic with this in equalTo(int, T) by @fp7 in https://github.com/immutables/immutables/pull/1361
    • Using (lazyhash = true)+Serializable should always make the computed hashCode field transient by @nastra in https://github.com/immutables/immutables/pull/1369
    • Improve error msg for null values in JDK Maps by @nastra in https://github.com/immutables/immutables/pull/1371
    • Could org.immutables:testing:2.9.1-SNAPSHOT drop off redundant dependencies? by @Celebrate-future in https://github.com/immutables/immutables/pull/1382

    New Contributors

    • @garrettlestingi made their first contribution in https://github.com/immutables/immutables/pull/1190
    • @joke made their first contribution in https://github.com/immutables/immutables/pull/1191
    • @SimY4 made their first contribution in https://github.com/immutables/immutables/pull/1212
    • @dmivankov made their first contribution in https://github.com/immutables/immutables/pull/1221
    • @jbewing made their first contribution in https://github.com/immutables/immutables/pull/1226
    • @realumhelp made their first contribution in https://github.com/immutables/immutables/pull/1224
    • @stepancheg made their first contribution in https://github.com/immutables/immutables/pull/1123
    • @sullis made their first contribution in https://github.com/immutables/immutables/pull/1244
    • @aaylward made their first contribution in https://github.com/immutables/immutables/pull/1292
    • @darichey made their first contribution in https://github.com/immutables/immutables/pull/1320
    • @wisecodecraft made their first contribution in https://github.com/immutables/immutables/pull/1343
    • @pthariensflame made their first contribution in https://github.com/immutables/immutables/pull/1350
    • @dhoepelman made their first contribution in https://github.com/immutables/immutables/pull/1347
    • @fp7 made their first contribution in https://github.com/immutables/immutables/pull/1361
    • @nastra made their first contribution in https://github.com/immutables/immutables/pull/1369
    • @Celebrate-future made their first contribution in https://github.com/immutables/immutables/pull/1382
    Source code(tar.gz)
    Source code(zip)
  • 2.8.8(May 8, 2020)

    Value

    • Predictable encoding conflict resolution by Ivan Abarca (#1170 66166f3f)

    Criteria

    • Add toLowerCase / toUpperCase functions to StringMatcher (6e4dd31c9)
    • Add GetByKey / DeleteByKey operations which allow low-level key lookups and deletions (ce9ad50b39)
    • Add isNot(boolean) function to BooleanMatcher (c9c6305c)
    • Add is(Optional) / isNot(Optional) to generic OptionalValueMatcher (0c2d47ec8e5f)
    • Add is(Optional) / isNot(Optional) functions to OptionalBooleanMatcher (c41ffaf53)

    Dependency Upgrades

    • mongo-java-server 1.19.0 -> 1.28.0 (493eafef0e)
    • mongo java driver (sync) 3.11.0 -> 3.12.3 (22337f33)
    • mongo java driver (reactive streams) 1.12.0 -> 1.13.1 (1c34b7f3)
    • jackson-databind 2.8.11.4 -> 2.8.11.6 (8a2aa885cf)
    • rxjava2 2.2.12 -> 2.2.19 (be75e8d29)
    • Project Reactor 3.2.12 -> 3.3.5 (13932b2)
    • JUnit5 upgrade 5.5.2 -> 5.6.2 (b0b0a8a5)

    Contributors

    Thanks to all contributors. In no particular order:

    Source code(tar.gz)
    Source code(zip)
  • 2.8.4(Apr 27, 2020)

    Introduce KeyExtractor interface to Criteria for pluggable entity key definition and extraction. Other improvements in different backend implementations.

    Support for Modifiables to extend an inner class/interface.

    Value

    1. Add support for Modifiable to extend an inner class/interface by Mitch Halpin (67f808358672)

    Criteria

    1. Pluggable KeyExtractor interface (3eb6958db5)
    2. Add projection support for iterable type(s) like List<String> (78c7c29ced)
    3. Add support for Fugue Option to CriteriaModel by Charlie La Mothe (207d631d8c)

    Geode

    1. add tests for generating OQL expressions by Javad Moghisi (0c5e5e3f18)
    2. include order by direction in OQL by Javad Moghisi (5c3d15b1f3c)
    3. add support for Iterable Size and Contains to OQL Generator by Javad Moghisi (cfb514bfe)
    4. add support for String Operators to OQL Generator by Javad Moghisi(43f4fff8)

    ElasticSearch

    1. Use more efficient id lookups for key attributes in ElasticSearch backend (db4fa9804ea)

    Mongo

    1. Add mongo optimization to convert $in/$nin into $eq/$ne for single element array (09c002cca)

    Mongo Repositories (legacy)

    1. Fix suppress warnings for generated MongoDB repositories by André Rouél (1afdfa44f7)

    Contributors

    Thanks to all contributors! In no particular order:

    • Javad Moghisi (@jmoghisi)
    • Mitch Halpin (@kiddkaffeine)
    • André Rouél (@arouel)
    • Blake Hurlburt (@blakehurlburt)
    • The Alchemis (@The-Alchemist)
    • Charlie La Mothe (@clamothe)
    Source code(tar.gz)
    Source code(zip)
  • 2.8.3(Dec 12, 2019)

    Minor release fixing a couple of bugs in Geode backend :

    1. Use JDK collections for geode bind variables when sending query to server (7cc1fb818)
    2. Prefer Region.getAll() method for queries which filter only on ID attribute (5426af61)
    3. Drop ContainerResolver interface (cb9d064)
    4. Drop NamingStrategy interface (764d3b5)
    Source code(tar.gz)
    Source code(zip)
  • 2.8.2(Nov 16, 2019)

    Main feature of this release is DISTINCT statement in Criteria. Plus, small functionalities and bugfixes.

    Notable changes

    Criteria

    • Support for DISTINCT modifier in queries. Simple DSL to allow chaining DISTINCT / LIMIT / OFFSET modifiers (9d639225)
    // example of DISTINCT query
    repository.find(person.isActive.isTrue())
         .orderBy(person.name.asc())
         .select(person.name)
         .distinct()
         .limit(2)
         .fetch();
    

    Geode backend

    Codegen

    • Remove unnecessary empty line between hashCode() and toString() functions introduced by previous commit
    • Suppress ErrorProne error (with @SuppressWarnings(Immutable)) for lazy hashCode field (#1114)

    Gson / JSON Adapters

    • Fixed issue where integers are always printed as doubles (#1120) by Ben Mazzarol (@bmazzarol)
    • Fixed issue using the jackson XML streaming parser where boolean tokens are always strings (#1120) by Ben Mazzarol (@bmazzarol)

    Other changes

    • Change dependency scope of jackson-datatype-guava and jackson-datatype-jdk8 to test in ElasticSearch backend. They were used only in tests.
    • Enable errorprone static analysis in criteria module (ef5f1a267)

    Thanks to all contributors:

    Source code(tar.gz)
    Source code(zip)
  • 2.8.1(Oct 19, 2019)

    Immutables team is happy to announce Immutables 2.8.1 release.

    This release 2.8.1 comes one month after 2.8.0 and contains several improvements, bugfixes and new functionalities.

    Notable changes

    Criteria

    • Generate criteria DSL from existing JavaBeans(spec) classes. Useful for projects which use JavaBeans for legacy reasons or not yet fully migrated to immutables. See #1103
    • Pluggable ID resolution. Introduce IdResolver interface to allow users to provide their own annotations (or logic) for ID attribute selection. It complements default @Criteria.Id annotation.
    • Initial support for partial updates. Allow partial changes to be applied directly by the backend (if supported).
    repository.update(person.id.is(123))
      .set(person.name, "Changed Name")
      .set(person.age, 33)
      .execute()
    
    • Support top-level count() operation similar to COUNT(*) in SQL
    repository.findAll().count();
    repository.find(person.age.greaterThan(33)).count();
    
    • Add upsert / update operations on entity in Writable interface

    Mongo jackson adapter

    • Support BSON undefined type which is converted to java null (9a64881)
    • Support BSON binary data (76fb7b44)
    • Lazily read values from bson stream (1c07466). Potentially a performance improvement since values don't have to be deserialized unless required by deserializer. Allows faster skipChildren() calls.
    • Make BsonGenerator null safe on strings and numbers (ba78d7)

    Mongo repositories

    Changes related to mongo repositories (predecessor to criteria).

    • Enable _id initialization in MongoDB (#1074). PR from André Rouél
    • bson4gson adapter. Support BSON undefined type translated to java null
    • bson4gson adapter. Friendlier type conversion between BSON temporal types and java numbers (int / long etc.)
    • bson4gson adapter. Fix peek() method in JsonReader (6f1247)
    • Require Java 8

    Codegen

    • Support lazy hashing via lazyhash attribute. Contrary to existing prehash, lazyhash would compute hashcode on first access to hashCode() method.
    • Changed how META-INF/annotations/org.immutables.value.immutable is read - disabled URLConnection caching. PR-1060 from Canay ÖZEL
    • Set optBits for Modifiable, Default maps. PR-1086 from Dylan Wragge

    Third party library upgrades and other dependencies

    • Jackson databind 2.8.11.3 -> 2.8.11.4 (9ea18)
    • Mongo java (sync) driver 3.10.1 -> 3.11.0 (33f98d4)
    • Mongo reactive streams 1.11 -> 1.12 (fed2e07)
    • rxjava2 2.2.10 -> 2.2.12 (c6e06ce)
    • ErrorProne 2.3.2 -> 2.3.3 (b62fab4f)
    • Remove utility maven module (1089). All modules will declare dependencies explicitly.

    Thanks to all contributors. In no particular order:

    Source code(tar.gz)
    Source code(zip)
  • 2.8.0(Sep 20, 2019)

    (not a bugfix release yet, sorry, expect more bugfixes in 2.8.x versions)

    2.8.0 is available on Maven Central now

    Criteria & Repositories API

    Combine power of immutable objects with the flexibility of querying them

    Immutables team is pleased to announce Immutables 2.8.0 release.

    Major focus of this release was Criteria API which enables users to generate model-specific query DSL. Generated class (along with criteria runtime) allows accessing different backends in a unified, fluent and type-safe manner.

    Benefits over raw driver API usage or string based abstractions (DSLs) are:

    1. Compile-time checking and type safety allows for much fewer mistakes
    2. IDE auto-completion guides through the choice of fields and operators
    3. Best in class readability due to drastically reduced number of parentheses and specially designed DNF approach
    4. Easier model refactoring

    Benefits over existing frameworks like Spring Data, Morphia, QueryDSL or jOOQ are:

    1. Derive immutable implementation, query DSL, repository and more from a single definition
    2. Pluggable Sync / Async / Reactive execution models
    3. Pluggable backend implementations
    4. Generated or custom Repositories (aka DAOs) can be controlled to generate reading / writing or watching operations on entities

    Full release announcement here: https://github.com/immutables/immutables.github.io/blob/src/2.8.0-release.md Getting started with criteria API: https://immutables.github.io/criteria.html

    Source code(tar.gz)
    Source code(zip)
Owner
Immutables
Java toolkits around immutability, annotation processing and high performance
Immutables
Generate Java types from JSON or JSON Schema and annotates those types for data-binding with Jackson, Gson, etc

jsonschema2pojo jsonschema2pojo generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x

Joe Littlejohn 5.9k Jan 5, 2023
GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections. https://www.eclipse.org/collections/

GS Collections is now Eclipse Collections We are pleased to announce that GS Collections has been migrated to the Eclipse Foundation, re-branded as Ec

null 1.8k Dec 30, 2022
GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections. https://www.eclipse.org/collections/

GS Collections is now Eclipse Collections We are pleased to announce that GS Collections has been migrated to the Eclipse Foundation, re-branded as Ec

null 1.8k Dec 30, 2022
SecureDB is an extension for Ai2 Appinventor and its distros which stores the data in the form of key and value just like TinyDB but in a more secure manner.

SecureDB SecureDB is an extension for Ai2 Appinventor and its distros which stores data for your app in a secure format locally on user's device. Expl

Akshat Developer 3 Sep 24, 2022
Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer.

json-io Perfect Java serialization to and from JSON format (available on Maven Central). To include in your project: <dependency> <groupId>com.cedar

John DeRegnaucourt 303 Dec 30, 2022
MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Andrei Ciobanu 59 Sep 17, 2022
A simple java json configuration system built with gson.

Simple Configuration A simple json configuration system built with gson. Setup ?? Using Maven REPOSITORY <repositories> <repository> <id>j

Kacper Horbacz 2 Sep 24, 2022
Immutable key/value store with efficient space utilization and fast reads. They are ideal for the use-case of tables built by batch processes and shipped to multiple servers.

Minimal Perfect Hash Tables About Minimal Perfect Hash Tables are an immutable key/value store with efficient space utilization and fast reads. They a

Indeed Engineering 92 Nov 22, 2022
Java 8 annotation processor and framework for deriving algebraic data types constructors, pattern-matching, folds, optics and typeclasses.

Derive4J: Java 8 annotation processor for deriving algebraic data types constructors, pattern matching and more! tl;dr Show me how to write, say, the

null 543 Nov 23, 2022
Java 8 annotation processor and framework for deriving algebraic data types constructors, pattern-matching, folds, optics and typeclasses.

Derive4J: Java 8 annotation processor for deriving algebraic data types constructors, pattern matching and more! tl;dr Show me how to write, say, the

null 543 Nov 23, 2022
Persistent (immutable) collections for Java and Kotlin

What are Dexx Collections? Dexx Collections are a port of Scala's immutable, persistent collection classes to pure Java. Persistent in the context of

Andrew O'Malley 208 Sep 30, 2022
An annotation processor for generating type-safe bean mappers

MapStruct - Java bean mappings, the easy way! What is MapStruct? Requirements Using MapStruct Maven Gradle Documentation and getting help Building fro

null 5.8k Dec 31, 2022
A Java annotation processor used for automatically generating better builder codes.

BetterBuilder BetterBuilder is a Java annotation processor used for automatically generating better builder codes(builder design pattern), which can m

LEO D PEN 9 Apr 6, 2021
Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.

English | 中文 | Deutsch | Español | Ελληνικά | Français | 日本語 | Norsk (bokmål) | Português-Brasil | Русский | हिंदी Eclipse Collections is a comprehens

Eclipse Foundation 2.1k Jan 5, 2023
Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.

English | 中文 | Deutsch | Español | Ελληνικά | Français | 日本語 | Norsk (bokmål) | Português-Brasil | Русский | हिंदी Eclipse Collections is a comprehens

Eclipse Foundation 2.1k Dec 29, 2022
sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.

sql2o Sql2o is a small java library, with the purpose of making database interaction easy. When fetching data from the database, the ResultSet will au

Lars Aaberg 1.1k Dec 28, 2022
Fluent builders with typesafe API for the JCA

Security Builders This library implements a set of "fluent" API builders for the java.security classes, and provides more typesafe, intuitive API to a

Terse Systems 44 Sep 13, 2022
Ever wondered how a baloon feels in a dangerous place? Now you know.

Dont-Pop Description Ever wondered how a balloon feels in a dangerous place? Now you know. This game belongs to the category of Survival Games: the pl

Michele Ravaioli 9 Oct 24, 2022
JSON Web Token implementation for Java according to RFC 7519. Easily create, parse and validate JSON Web Tokens using a fluent API.

JWT-Java JSON Web Token library for Java according to RFC 7519. Table of Contents What are JSON Web Tokens? Header Payload Signature Features Supporte

Bastiaan Jansen 6 Jul 10, 2022