Skip to content

Commit 63790ea

Browse files
authored
Merge pull request GoogleCloudPlatform#439 from GoogleCloudPlatform/tswast-autovalue
Remove dependency on AutoValue.
2 parents d0d4165 + f27a950 commit 63790ea

File tree

5 files changed

+93
-35
lines changed

5 files changed

+93
-35
lines changed

vision/text/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@
5050
<artifactId>guava</artifactId>
5151
<version>20.0</version>
5252
</dependency>
53-
<dependency>
54-
<groupId>com.google.auto.value</groupId>
55-
<artifactId>auto-value</artifactId>
56-
<version>1.3</version>
57-
<scope>provided</scope>
58-
</dependency>
5953
<dependency>
6054
<groupId>org.apache.opennlp</groupId>
6155
<artifactId>opennlp-tools</artifactId>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import com.google.api.services.vision.v1.model.EntityAnnotation;
2020
import com.google.api.services.vision.v1.model.Status;
21-
import com.google.auto.value.AutoValue;
2221

2322
import java.nio.file.Path;
2423
import java.util.List;
@@ -28,28 +27,58 @@
2827
/**
2928
* A data object for mapping text to file paths.
3029
*/
31-
@AutoValue
32-
abstract class ImageText {
30+
public class ImageText {
31+
private Path pth;
32+
private List<EntityAnnotation> ts;
33+
private Status err;
3334

3435
public static Builder builder() {
35-
return new AutoValue_ImageText.Builder();
36+
return new Builder();
3637
}
3738

38-
public abstract Path path();
39+
private ImageText() {}
3940

40-
public abstract List<EntityAnnotation> textAnnotations();
41+
public Path path() {
42+
return this.pth;
43+
}
44+
45+
public List<EntityAnnotation> textAnnotations() {
46+
return this.ts;
47+
}
4148

4249
@Nullable
43-
public abstract Status error();
50+
public Status error() {
51+
return this.err;
52+
}
53+
54+
public static class Builder {
55+
private Path pth;
56+
private List<EntityAnnotation> ts;
57+
private Status err;
58+
59+
Builder() {}
4460

45-
@AutoValue.Builder
46-
public abstract static class Builder {
47-
public abstract Builder path(Path path);
61+
public Builder path(Path path) {
62+
this.pth = path;
63+
return this;
64+
}
4865

49-
public abstract Builder textAnnotations(List<EntityAnnotation> ts);
66+
public Builder textAnnotations(List<EntityAnnotation> ts) {
67+
this.ts = ts;
68+
return this;
69+
}
5070

51-
public abstract Builder error(@Nullable Status err);
71+
public Builder error(@Nullable Status err) {
72+
this.err = err;
73+
return this;
74+
}
5275

53-
public abstract ImageText build();
76+
public ImageText build() {
77+
ImageText out = new ImageText();
78+
out.pth = this.pth;
79+
out.ts = this.ts;
80+
out.err = this.err;
81+
return out;
82+
}
5483
}
5584
}

vision/text/src/main/java/com/google/cloud/vision/samples/text/Index.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

vision/text/src/main/java/com/google/cloud/vision/samples/text/TextApp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,30 +16,65 @@
1616

1717
package com.google.cloud.vision.samples.text;
1818

19-
import com.google.auto.value.AutoValue;
20-
2119
import java.nio.file.Path;
2220

2321
/**
2422
* A data object for mapping words to file paths.
2523
*/
26-
@AutoValue
27-
abstract class Word {
24+
public class Word {
25+
private Path pth;
26+
private String wrd;
2827

2928
public static Builder builder() {
30-
return new AutoValue_Word.Builder();
29+
return new Builder();
30+
}
31+
32+
public Path path() {
33+
return this.pth;
34+
}
35+
36+
public String word() {
37+
return this.wrd;
38+
}
39+
40+
@Override
41+
public boolean equals(Object other) {
42+
if (other == null) {
43+
return false;
44+
}
45+
if (!(other instanceof Word)) {
46+
return false;
47+
}
48+
Word otherWord = (Word) other;
49+
return this.path().equals(otherWord.path()) && this.word().equals(otherWord.word());
50+
}
51+
52+
@Override
53+
public int hashCode() {
54+
return this.word().hashCode() ^ this.path().hashCode();
3155
}
3256

33-
public abstract Path path();
57+
public static class Builder {
58+
private Path pth;
59+
private String wrd;
3460

35-
public abstract String word();
61+
Builder() {}
3662

37-
@AutoValue.Builder
38-
public abstract static class Builder {
39-
public abstract Builder path(Path path);
63+
public Builder path(Path path) {
64+
this.pth = path;
65+
return this;
66+
}
4067

41-
public abstract Builder word(String word);
68+
public Builder word(String word) {
69+
this.wrd = word;
70+
return this;
71+
}
4272

43-
public abstract Word build();
73+
public Word build() {
74+
Word out = new Word();
75+
out.pth = this.pth;
76+
out.wrd = this.wrd;
77+
return out;
78+
}
4479
}
4580
}

0 commit comments

Comments
 (0)