// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.protos.redacted_test.RedactedExtension in redacted_test.proto
package com.squareup.wire.protos.redacted;

import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.ReverseProtoWriter;
import com.squareup.wire.Syntax;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;

public final class RedactedExtension extends Message<RedactedExtension, RedactedExtension.Builder> {
  public static final ProtoAdapter<RedactedExtension> ADAPTER = new ProtoAdapter_RedactedExtension();

  private static final long serialVersionUID = 0L;

  public static final String DEFAULT_D = "";

  public static final String DEFAULT_E = "";

  @WireField(
      tag = 1,
      adapter = "com.squareup.wire.ProtoAdapter#STRING",
      redacted = true
  )
  public final String d;

  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#STRING"
  )
  public final String e;

  public RedactedExtension(String d, String e) {
    this(d, e, ByteString.EMPTY);
  }

  public RedactedExtension(String d, String e, ByteString unknownFields) {
    super(ADAPTER, unknownFields);
    this.d = d;
    this.e = e;
  }

  @Override
  public Builder newBuilder() {
    Builder builder = new Builder();
    builder.d = d;
    builder.e = e;
    builder.addUnknownFields(unknownFields());
    return builder;
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) return true;
    if (!(other instanceof RedactedExtension)) return false;
    RedactedExtension o = (RedactedExtension) other;
    return unknownFields().equals(o.unknownFields())
        && Internal.equals(d, o.d)
        && Internal.equals(e, o.e);
  }

  @Override
  public int hashCode() {
    int result = super.hashCode;
    if (result == 0) {
      result = unknownFields().hashCode();
      result = result * 37 + (d != null ? d.hashCode() : 0);
      result = result * 37 + (e != null ? e.hashCode() : 0);
      super.hashCode = result;
    }
    return result;
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    if (d != null) builder.append(", d=██");
    if (e != null) builder.append(", e=").append(Internal.sanitize(e));
    return builder.replace(0, 2, "RedactedExtension{").append('}').toString();
  }

  public static final class Builder extends Message.Builder<RedactedExtension, Builder> {
    public String d;

    public String e;

    public Builder() {
    }

    public Builder d(String d) {
      this.d = d;
      return this;
    }

    public Builder e(String e) {
      this.e = e;
      return this;
    }

    @Override
    public RedactedExtension build() {
      return new RedactedExtension(d, e, super.buildUnknownFields());
    }
  }

  private static final class ProtoAdapter_RedactedExtension extends ProtoAdapter<RedactedExtension> {
    public ProtoAdapter_RedactedExtension() {
      super(FieldEncoding.LENGTH_DELIMITED, RedactedExtension.class, "type.googleapis.com/squareup.protos.redacted_test.RedactedExtension", Syntax.PROTO_2, null, "redacted_test.proto");
    }

    @Override
    public int encodedSize(RedactedExtension value) {
      int result = 0;
      result += ProtoAdapter.STRING.encodedSizeWithTag(1, value.d);
      result += ProtoAdapter.STRING.encodedSizeWithTag(2, value.e);
      result += value.unknownFields().size();
      return result;
    }

    @Override
    public void encode(ProtoWriter writer, RedactedExtension value) throws IOException {
      ProtoAdapter.STRING.encodeWithTag(writer, 1, value.d);
      ProtoAdapter.STRING.encodeWithTag(writer, 2, value.e);
      writer.writeBytes(value.unknownFields());
    }

    @Override
    public void encode(ReverseProtoWriter writer, RedactedExtension value) throws IOException {
      writer.writeBytes(value.unknownFields());
      ProtoAdapter.STRING.encodeWithTag(writer, 2, value.e);
      ProtoAdapter.STRING.encodeWithTag(writer, 1, value.d);
    }

    @Override
    public RedactedExtension decode(ProtoReader reader) throws IOException {
      Builder builder = new Builder();
      long token = reader.beginMessage();
      for (int tag; (tag = reader.nextTag()) != -1;) {
        switch (tag) {
          case 1: builder.d(ProtoAdapter.STRING.decode(reader)); break;
          case 2: builder.e(ProtoAdapter.STRING.decode(reader)); break;
          default: {
            reader.readUnknownField(tag);
          }
        }
      }
      builder.addUnknownFields(reader.endMessageAndGetUnknownFields(token));
      return builder.build();
    }

    @Override
    public RedactedExtension redact(RedactedExtension value) {
      Builder builder = value.newBuilder();
      builder.d = null;
      builder.clearUnknownFields();
      return builder.build();
    }
  }
}
