-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
174 changed files
with
580 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
264 changes: 264 additions & 0 deletions
264
wire-golden-files/src/main/java/squareup/java/dinosaurs/Dinosaur.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,264 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.java.dinosaurs.Dinosaur in squareup/wire/java/dinosaurs/dinosaur.proto | ||
package squareup.java.dinosaurs; | ||
|
||
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.Double; | ||
import java.lang.Object; | ||
import java.lang.Override; | ||
import java.lang.String; | ||
import java.lang.StringBuilder; | ||
import java.util.List; | ||
import okio.ByteString; | ||
import squareup.java.geology.Period; | ||
|
||
public final class Dinosaur extends Message<Dinosaur, Dinosaur.Builder> { | ||
public static final ProtoAdapter<Dinosaur> ADAPTER = new ProtoAdapter_Dinosaur(); | ||
|
||
private static final long serialVersionUID = 0L; | ||
|
||
public static final String DEFAULT_NAME = ""; | ||
|
||
public static final Double DEFAULT_LENGTH_METERS = 0.0d; | ||
|
||
public static final Double DEFAULT_MASS_KILOGRAMS = 0.0d; | ||
|
||
public static final Period DEFAULT_PERIOD = Period.CRETACEOUS; | ||
|
||
/** | ||
* Common name of this dinosaur, like "Stegosaurus". | ||
*/ | ||
@WireField( | ||
tag = 1, | ||
adapter = "com.squareup.wire.ProtoAdapter#STRING" | ||
) | ||
public final String name; | ||
|
||
/** | ||
* URLs with images of this dinosaur. | ||
*/ | ||
@WireField( | ||
tag = 2, | ||
adapter = "com.squareup.wire.ProtoAdapter#STRING", | ||
label = WireField.Label.REPEATED | ||
) | ||
public final List<String> picture_urls; | ||
|
||
@WireField( | ||
tag = 3, | ||
adapter = "com.squareup.wire.ProtoAdapter#DOUBLE" | ||
) | ||
public final Double length_meters; | ||
|
||
@WireField( | ||
tag = 4, | ||
adapter = "com.squareup.wire.ProtoAdapter#DOUBLE" | ||
) | ||
public final Double mass_kilograms; | ||
|
||
@WireField( | ||
tag = 5, | ||
adapter = "squareup.java.geology.Period#ADAPTER" | ||
) | ||
public final Period period; | ||
|
||
public Dinosaur(String name, List<String> picture_urls, Double length_meters, | ||
Double mass_kilograms, Period period) { | ||
this(name, picture_urls, length_meters, mass_kilograms, period, ByteString.EMPTY); | ||
} | ||
|
||
public Dinosaur(String name, List<String> picture_urls, Double length_meters, | ||
Double mass_kilograms, Period period, ByteString unknownFields) { | ||
super(ADAPTER, unknownFields); | ||
this.name = name; | ||
this.picture_urls = Internal.immutableCopyOf("picture_urls", picture_urls); | ||
this.length_meters = length_meters; | ||
this.mass_kilograms = mass_kilograms; | ||
this.period = period; | ||
} | ||
|
||
@Override | ||
public Builder newBuilder() { | ||
Builder builder = new Builder(); | ||
builder.name = name; | ||
builder.picture_urls = Internal.copyOf(picture_urls); | ||
builder.length_meters = length_meters; | ||
builder.mass_kilograms = mass_kilograms; | ||
builder.period = period; | ||
builder.addUnknownFields(unknownFields()); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) return true; | ||
if (!(other instanceof Dinosaur)) return false; | ||
Dinosaur o = (Dinosaur) other; | ||
return unknownFields().equals(o.unknownFields()) | ||
&& Internal.equals(name, o.name) | ||
&& picture_urls.equals(o.picture_urls) | ||
&& Internal.equals(length_meters, o.length_meters) | ||
&& Internal.equals(mass_kilograms, o.mass_kilograms) | ||
&& Internal.equals(period, o.period); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = super.hashCode; | ||
if (result == 0) { | ||
result = unknownFields().hashCode(); | ||
result = result * 37 + (name != null ? name.hashCode() : 0); | ||
result = result * 37 + picture_urls.hashCode(); | ||
result = result * 37 + (length_meters != null ? length_meters.hashCode() : 0); | ||
result = result * 37 + (mass_kilograms != null ? mass_kilograms.hashCode() : 0); | ||
result = result * 37 + (period != null ? period.hashCode() : 0); | ||
super.hashCode = result; | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
if (name != null) builder.append(", name=").append(Internal.sanitize(name)); | ||
if (!picture_urls.isEmpty()) builder.append(", picture_urls=").append(Internal.sanitize(picture_urls)); | ||
if (length_meters != null) builder.append(", length_meters=").append(length_meters); | ||
if (mass_kilograms != null) builder.append(", mass_kilograms=").append(mass_kilograms); | ||
if (period != null) builder.append(", period=").append(period); | ||
return builder.replace(0, 2, "Dinosaur{").append('}').toString(); | ||
} | ||
|
||
public static final class Builder extends Message.Builder<Dinosaur, Builder> { | ||
public String name; | ||
|
||
public List<String> picture_urls; | ||
|
||
public Double length_meters; | ||
|
||
public Double mass_kilograms; | ||
|
||
public Period period; | ||
|
||
public Builder() { | ||
picture_urls = Internal.newMutableList(); | ||
} | ||
|
||
/** | ||
* Common name of this dinosaur, like "Stegosaurus". | ||
*/ | ||
public Builder name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
/** | ||
* URLs with images of this dinosaur. | ||
*/ | ||
public Builder picture_urls(List<String> picture_urls) { | ||
Internal.checkElementsNotNull(picture_urls); | ||
this.picture_urls = picture_urls; | ||
return this; | ||
} | ||
|
||
public Builder length_meters(Double length_meters) { | ||
this.length_meters = length_meters; | ||
return this; | ||
} | ||
|
||
public Builder mass_kilograms(Double mass_kilograms) { | ||
this.mass_kilograms = mass_kilograms; | ||
return this; | ||
} | ||
|
||
public Builder period(Period period) { | ||
this.period = period; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Dinosaur build() { | ||
return new Dinosaur(name, picture_urls, length_meters, mass_kilograms, period, super.buildUnknownFields()); | ||
} | ||
} | ||
|
||
private static final class ProtoAdapter_Dinosaur extends ProtoAdapter<Dinosaur> { | ||
public ProtoAdapter_Dinosaur() { | ||
super(FieldEncoding.LENGTH_DELIMITED, Dinosaur.class, "type.googleapis.com/squareup.java.dinosaurs.Dinosaur", Syntax.PROTO_2.INSTANCE, null, "squareup/wire/java/dinosaurs/dinosaur.proto"); | ||
} | ||
|
||
@Override | ||
public int encodedSize(Dinosaur value) { | ||
int result = 0; | ||
result += ProtoAdapter.STRING.encodedSizeWithTag(1, value.name); | ||
result += ProtoAdapter.STRING.asRepeated().encodedSizeWithTag(2, value.picture_urls); | ||
result += ProtoAdapter.DOUBLE.encodedSizeWithTag(3, value.length_meters); | ||
result += ProtoAdapter.DOUBLE.encodedSizeWithTag(4, value.mass_kilograms); | ||
result += Period.ADAPTER.encodedSizeWithTag(5, value.period); | ||
result += value.unknownFields().size(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public void encode(ProtoWriter writer, Dinosaur value) throws IOException { | ||
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.name); | ||
ProtoAdapter.STRING.asRepeated().encodeWithTag(writer, 2, value.picture_urls); | ||
ProtoAdapter.DOUBLE.encodeWithTag(writer, 3, value.length_meters); | ||
ProtoAdapter.DOUBLE.encodeWithTag(writer, 4, value.mass_kilograms); | ||
Period.ADAPTER.encodeWithTag(writer, 5, value.period); | ||
writer.writeBytes(value.unknownFields()); | ||
} | ||
|
||
@Override | ||
public void encode(ReverseProtoWriter writer, Dinosaur value) throws IOException { | ||
writer.writeBytes(value.unknownFields()); | ||
Period.ADAPTER.encodeWithTag(writer, 5, value.period); | ||
ProtoAdapter.DOUBLE.encodeWithTag(writer, 4, value.mass_kilograms); | ||
ProtoAdapter.DOUBLE.encodeWithTag(writer, 3, value.length_meters); | ||
ProtoAdapter.STRING.asRepeated().encodeWithTag(writer, 2, value.picture_urls); | ||
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.name); | ||
} | ||
|
||
@Override | ||
public Dinosaur 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.name(ProtoAdapter.STRING.decode(reader)); break; | ||
case 2: builder.picture_urls.add(ProtoAdapter.STRING.decode(reader)); break; | ||
case 3: builder.length_meters(ProtoAdapter.DOUBLE.decode(reader)); break; | ||
case 4: builder.mass_kilograms(ProtoAdapter.DOUBLE.decode(reader)); break; | ||
case 5: { | ||
try { | ||
builder.period(Period.ADAPTER.decode(reader)); | ||
} catch (ProtoAdapter.EnumConstantNotFoundException e) { | ||
builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value); | ||
} | ||
break; | ||
} | ||
default: { | ||
reader.readUnknownField(tag); | ||
} | ||
} | ||
} | ||
builder.addUnknownFields(reader.endMessageAndGetUnknownFields(token)); | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public Dinosaur redact(Dinosaur value) { | ||
Builder builder = value.newBuilder(); | ||
builder.clearUnknownFields(); | ||
return builder.build(); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
wire-golden-files/src/main/java/squareup/java/geology/Period.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.java.geology.Period in squareup/wire/java/geology/period.proto | ||
package squareup.java.geology; | ||
|
||
import com.squareup.wire.EnumAdapter; | ||
import com.squareup.wire.ProtoAdapter; | ||
import com.squareup.wire.Syntax; | ||
import com.squareup.wire.WireEnum; | ||
import java.lang.Override; | ||
|
||
public enum Period implements WireEnum { | ||
/** | ||
* 145.5 million years ago — 66.0 million years ago. | ||
*/ | ||
CRETACEOUS(1), | ||
|
||
/** | ||
* 201.3 million years ago — 145.0 million years ago. | ||
*/ | ||
JURASSIC(2), | ||
|
||
/** | ||
* 252.17 million years ago — 201.3 million years ago. | ||
*/ | ||
TRIASSIC(3); | ||
|
||
public static final ProtoAdapter<Period> ADAPTER = new ProtoAdapter_Period(); | ||
|
||
private final int value; | ||
|
||
Period(int value) { | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Return the constant for {@code value} or null. | ||
*/ | ||
public static Period fromValue(int value) { | ||
switch (value) { | ||
case 1: return CRETACEOUS; | ||
case 2: return JURASSIC; | ||
case 3: return TRIASSIC; | ||
default: return null; | ||
} | ||
} | ||
|
||
@Override | ||
public int getValue() { | ||
return value; | ||
} | ||
|
||
private static final class ProtoAdapter_Period extends EnumAdapter<Period> { | ||
ProtoAdapter_Period() { | ||
super(Period.class, Syntax.PROTO_2.INSTANCE, null); | ||
} | ||
|
||
@Override | ||
protected Period fromValue(int value) { | ||
return Period.fromValue(value); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
wire-golden-files/src/main/proto/squareup/wire/java/dinosaurs/dinosaur.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto2"; | ||
|
||
package squareup.java.dinosaurs; | ||
|
||
import "squareup/wire/java/geology/period.proto"; | ||
|
||
message Dinosaur { | ||
/** Common name of this dinosaur, like "Stegosaurus". */ | ||
optional string name = 1; | ||
|
||
/** URLs with images of this dinosaur. */ | ||
repeated string picture_urls = 2; | ||
|
||
optional double length_meters = 3; | ||
optional double mass_kilograms = 4; | ||
optional squareup.java.geology.Period period = 5; | ||
} |
14 changes: 14 additions & 0 deletions
14
wire-golden-files/src/main/proto/squareup/wire/java/geology/period.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto2"; | ||
|
||
package squareup.java.geology; | ||
|
||
enum Period { | ||
/** 145.5 million years ago — 66.0 million years ago. */ | ||
CRETACEOUS = 1; | ||
|
||
/** 201.3 million years ago — 145.0 million years ago. */ | ||
JURASSIC = 2; | ||
|
||
/** 252.17 million years ago — 201.3 million years ago. */ | ||
TRIASSIC = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.