Questions tagged [auto-value]

Immutable value type code generation for Java 1.6+.

AutoValue, a part of Google's open source auto project, makes creating immutable value type classes in Java easy.

Documentation can be found here.

118 questions
1
vote
2 answers

AutoValue Gson Extension not creating AutoValueGsonTypeAdapterFactory

I'm trying to use AutoValueGsonTypeAdapterFactory but the class is never generated. Here is my implementation. @AutoValue public abstract class Foo { public abstract String bar(); @SerializedName("Baz") abstract String baz(); public…
Abdelrhman Talat
  • 1,205
  • 2
  • 13
  • 25
1
vote
1 answer

How to add day to date in yii2?

how to add day to date yii2? when i enter checkin and hari, then value in checkout = checkin+hari. can you help me? thanks. This is my code in form yii2, if date picker tanggal_masuk anda field jumlah_hari enter the data, then date picker =…
1
vote
2 answers

Unable to convert JSON to ArrayList when using AutoValue

I am using AutoValue to for things like getter/setter and Parcelable. I am storing the JSON value of objects in SharedPreferences and then retrieving them when needed. However, this throws an exception when I try to convert the JSON array stored as…
yadav_vi
  • 1,289
  • 4
  • 16
  • 46
1
vote
1 answer

AutoValue: ClassCastException: LinkedTreeMap cannot be cast to

First of all, i'm using retrofit with gson and autovalue-gson extension Check here : https://github.com/rharter/auto-value-gson In API i have a different models, where API returns json with id, description etc and also array of messages, but these…
mayosk
  • 603
  • 3
  • 14
1
vote
1 answer

Android Studio not picking up AutoParcelGson (AutoValue) classes from Java module

I've got an Android project with 2 modules, 1 Android and 1 Java, I'm using the AutoParcelGson AutoValue fork in both modules, and they work fine for generating classes and the build will run, however in Android Studio it only resolves the classes…
kassim
  • 3,880
  • 3
  • 26
  • 27
1
vote
1 answer

How to add setters using AutoValue extension in gson

I recently came across the concept of using AutoValues (GSON) extension to speed up parsing our json data. We actuall found it parsed our json twice as fast. But I am missing a point, the data set while using AutoValues is immutable, but often our…
ichthyocentaurs
  • 2,173
  • 21
  • 35
1
vote
1 answer

AutoValue and ActiveAndroid

Has anyone tried using both AutoValue and ActiveAndroid (or Ollie) on the same class? Right now I am trying to use a library called ActiveAndroid to save data to the sqlite database. The library is structured by adding annotation, @Column, for each…
1
vote
1 answer

GWT Serialization exception with AutoValue

According to AutoValue documentation annotating the abstract class with @GwtCompatible(serializable = true) and implementing serializable should be enough for the generated value class to be usable in GWT RPCs. Yet, with the class below I am getting…
Pierre-Antoine
  • 7,939
  • 6
  • 28
  • 36
1
vote
1 answer

Gradle dependency - com.google.auto:auto-common:1.0-SNAPSHOT

How do I get com.google.auto:auto-common:1.0-SNAPSHOT (transitive dependency) to resolve, in my gradle build? build.gradle: apply plugin: 'java' repositories { maven { mavenLocal() mavenCentral() url…
kd8azz
  • 613
  • 5
  • 21
0
votes
1 answer

How to add an element to the existing ImmutableSet - AutoValue?

Class Event { String eventName; Integer eventTime; .... // Event attributes with a builder } @AutoValue public abstract class XYZ { public abstract ImmutableSet events(); public abstract Event event(); public static Builder…
Senthil
  • 45
  • 1
  • 7
0
votes
1 answer

how to clear an `AutoValue` property via an `AutoValue.Builder`

I have an AutoValue with an Optional property. The AutoValue also has a Builder. Is there a way to use the Builder to clear the Optional property? I could not find anything about it in the AutoValue.Builder documentation. If this is not possible, is…
Chris Morris
  • 4,335
  • 4
  • 24
  • 28
0
votes
0 answers

how to pass AutoValue Builder as argument to AutoValue Builder's set() method (without defining the method myself)

I have an AutoValue with a property, SubMessage, that is also an AutoValue. The top-level AutoValue has a Builder that allows you to set the AutoValue SubMessage property with set(SubMessage). However, I get a compilation error when I declare a…
Chris Morris
  • 4,335
  • 4
  • 24
  • 28
0
votes
0 answers

compile error: nested AutoValue builder does not work when the object it builds is an Optional field

I have an AutoValue with an Optional field. The top-level AutoValue has a Builder that provides a nested Builder for the Optional field. However, there is a compilation error because the nested Builder returns the field, itself, instead of an…
Chris Morris
  • 4,335
  • 4
  • 24
  • 28
0
votes
0 answers

Asserting multiple attributes of an Object

In order to assert multiple attributes of a call, I am planning to use auto-value. But the documentation says: // You probably don't need to write assertions like these; just illustrating. assertTrue(Animal.create("dog", 4).equals(dog)); …
Sandeep Jindal
  • 14,510
  • 18
  • 83
  • 121
0
votes
1 answer

Replacing ImmutableMap keys in AutoValue with toBuilder()

I've come across a problem when using AutoValue with geneated Builder and fields with Guava ImmutableMap. Say we have this Container value class: public abstract class Container { public abstract ImmutableMap metadata(); …
Eddy
  • 1,662
  • 2
  • 21
  • 36