All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.norberg.automatter.example.BazBuilder Maven / Gradle / Ivy

package io.norberg.automatter.example;

import io.norberg.automatter.AutoMatter;
import javax.annotation.Generated;

@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
final class BazBuilder {
  private String foo;

  private Integer bar;

  private int baz;

  public BazBuilder() {
  }

  private BazBuilder(InheritanceExample.Baz v) {
    this.foo = v.foo();
    this.bar = v.bar();
    this.baz = v.baz();
  }

  private BazBuilder(BazBuilder v) {
    this.foo = v.foo;
    this.bar = v.bar;
    this.baz = v.baz;
  }

  public String foo() {
    return foo;
  }

  public BazBuilder foo(String foo) {
    if (foo == null) {
      throw new NullPointerException("foo");
    }
    this.foo = foo;
    return this;
  }

  public Integer bar() {
    return bar;
  }

  public BazBuilder bar(Integer bar) {
    if (bar == null) {
      throw new NullPointerException("bar");
    }
    this.bar = bar;
    return this;
  }

  public int baz() {
    return baz;
  }

  public BazBuilder baz(int baz) {
    this.baz = baz;
    return this;
  }

  public InheritanceExample.Baz build() {
    return new Value(foo, bar, baz);
  }

  public static BazBuilder from(InheritanceExample.Baz v) {
    return new BazBuilder(v);
  }

  public static BazBuilder from(BazBuilder v) {
    return new BazBuilder(v);
  }

  private static final class Value implements InheritanceExample.Baz {
    private final String foo;

    private final Integer bar;

    private final int baz;

    private Value(@AutoMatter.Field("foo") String foo, @AutoMatter.Field("bar") Integer bar, @AutoMatter.Field("baz") int baz) {
      if (foo == null) {
        throw new NullPointerException("foo");
      }
      if (bar == null) {
        throw new NullPointerException("bar");
      }
      this.foo = foo;
      this.bar = bar;
      this.baz = baz;
    }

    @AutoMatter.Field
    @Override
    public String foo() {
      return foo;
    }

    @AutoMatter.Field
    @Override
    public Integer bar() {
      return bar;
    }

    @AutoMatter.Field
    @Override
    public int baz() {
      return baz;
    }

    public BazBuilder builder() {
      return new BazBuilder(this);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (!(o instanceof InheritanceExample.Baz)) {
        return false;
      }
      final InheritanceExample.Baz that = (InheritanceExample.Baz) o;
      if (foo != null ? !foo.equals(that.foo()) : that.foo() != null) {
        return false;
      }
      if (bar != null ? !bar.equals(that.bar()) : that.bar() != null) {
        return false;
      }
      if (baz != that.baz()) {
        return false;
      }
      return true;
    }

    @Override
    public int hashCode() {
      int result = 1;
      long temp;
      result = 31 * result + (foo != null ? foo.hashCode() : 0);
      result = 31 * result + (bar != null ? bar.hashCode() : 0);
      result = 31 * result + baz;
      return result;
    }

    @Override
    public String toString() {
      return "InheritanceExample.Baz{" +
      "foo=" + foo +
      ", bar=" + bar +
      ", baz=" + baz +
      '}';
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy