1# Generated example
2
3
4For the code shown in the [introduction](index.md), the following is typical
5code AutoValue might generate:
6
7```java
8import javax.annotation.Generated;
9
10@Generated("com.google.auto.value.processor.AutoValueProcessor")
11final class AutoValue_Animal extends Animal {
12  private final String name;
13  private final int numberOfLegs;
14
15  AutoValue_Animal(String name, int numberOfLegs) {
16    if (name == null) {
17      throw new NullPointerException("Null name");
18    }
19    this.name = name;
20    this.numberOfLegs = numberOfLegs;
21  }
22
23  @Override
24  String name() {
25    return name;
26  }
27
28  @Override
29  int numberOfLegs() {
30    return numberOfLegs;
31  }
32
33  @Override
34  public String toString() {
35    return "Animal{"
36        + "name=" + name + ", "
37        + "numberOfLegs=" + numberOfLegs + "}";
38  }
39
40  @Override
41  public boolean equals(Object o) {
42    if (o == this) {
43      return true;
44    }
45    if (o instanceof Animal) {
46      Animal that = (Animal) o;
47      return this.name.equals(that.name())
48          && this.numberOfLegs == that.numberOfLegs();
49    }
50    return false;
51  }
52
53  @Override
54  public int hashCode() {
55    int h = 1;
56    h *= 1000003;
57    h ^= this.name.hashCode();
58    h *= 1000003;
59    h ^= this.numberOfLegs;
60    return h;
61  }
62}
63```
64