• Home
  • Raw
  • Download

Lines Matching refs:AutoValue

4 This page answers common how-to questions that may come up when using AutoValue.
8 for this, start by reading [AutoValue with builders](builders.md).
15 * ... [use AutoValue with a **nested** class?](#nested)
21 * ... [have AutoValue implement a concrete or default method?](#concrete)
25 * ... [have AutoValue also implement abstract methods from my
27 * ... [use AutoValue with a **generic** class?](#generic)
29 * ... [use AutoValue to **implement** an **annotation** type?](#annotation)
34 * ... [have one `@AutoValue` class **extend** another?](#inherit)
38 * ... [use AutoValue on an **interface**, not abstract class?](#interface)
48 Please see [AutoValue with builders](builders.md).
50 ## <a name="nested"></a>... use AutoValue with a nested class?
52 AutoValue composes the generated class name in the form
60 @AutoValue
74 AutoValue will do exactly this, but only if you are using these prefixes
88 accessor methods. This causes AutoValue to remove the null checks and generate
92 @AutoValue
103 `@Nullable`. AutoValue does not actually require this annotation, only the one
106 similarly the setter method of [AutoValue.Builder](builders)), but not the
123 AutoValue classes are meant and expected to be immutable. But sometimes you
133 @AutoValue
151 @AutoValue
168 accessor's return value. An example where something can go wrong: AutoValue
173 Simply write your custom implementation; AutoValue will notice this and will
177 Remember when doing this that you are losing AutoValue's protections. Be careful
185 readers that these methods aren't overridden by AutoValue.
187 ## <a name="concrete"></a>... have AutoValue implement a concrete or default method?
190 AutoValue to implement, you can *redeclare* it as abstract. This applies to
192 like to have AutoValue implement. It also applies to default methods in
196 @AutoValue
200 // cause AutoValue to generate this even though the superclass has it
206 @AutoValue
210 // cause AutoValue to implement this even though the interface has a default
218 Just do it! AutoValue doesn't actually care. This
238 @AutoValue
256 Note that this means the field is also ignored by `toString`; to AutoValue
259 ## <a name="supertypes"></a>... have AutoValue also implement abstract methods from my supertypes?
261 AutoValue will recognize every abstract accessor method whether it is defined
275 ## <a name="generic"></a>... use AutoValue with a generic class?
287 ## <a name="annotation"></a>... use AutoValue to implement an annotation type?
290 annotation instances. But if you do, using `@AutoValue` in the usual way will
292 AutoValue's behavior.
317 You can't; AutoValue only generates immutable value classes.
326 AutoValue intentionally does not provide this feature. It is better for you to
334 the flexibility you need, there's really no way for AutoValue to improve on
339 Go right ahead! AutoValue will generate code that acts on the *values* stored
354 ## <a name="inherit"></a>... have one `@AutoValue` class extend another?
362 We're sorry. This is one of the rare and unfortunate restrictions AutoValue's
368 We're sorry. This is one of the rare restrictions AutoValue's approach places on
372 ## <a name="interface"></a>... use AutoValue on an interface, not abstract class?
374 AutoValue classes can certainly implement an interface, however an interface may
385 AutoValue implements. You'd typically implement them with a concrete method that
389 @AutoValue
404 annotate it with [`@Memoized`]. Then AutoValue will override that method to
408 @AutoValue
440 @AutoValue
457 `@AutoValue` class can't inherit from another, two `@AutoValue` classes can
472 @AutoValue
482 @AutoValue
499 which property is set, there is an alternative to `@AutoValue` called
605 If you want to copy annotations from your `@AutoValue`-annotated class to the
607 [`@AutoValue.CopyAnnotations`].
612 @AutoValue
613 @AutoValue.CopyAnnotations
620 Then `@AutoValue` will generate `AutoValue_Example.java`:
629 Applying `@AutoValue.CopyAnnotations` to an `@AutoValue.Builder` class like
635 For historical reasons, annotations on methods of an `@AutoValue`-annotated
638 [`@AutoValue.CopyAnnotations`]'s `exclude` method to stop this behavior.
642 If you want to copy annotations from your `@AutoValue`-annotated class's methods
644 method with [`@AutoValue.CopyAnnotations`].
650 @AutoValue
660 Then `@AutoValue` will generate `AutoValue_Example.java`:
677 [`@AutoValue.CopyAnnotations`]: http://static.javadoc.io/com.google.auto.value/auto-value/1.6/com/g…