Skip to content

Remove dependency on AutoValue. #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions vision/text/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.opennlp</groupId>
<artifactId>opennlp-tools</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@

import com.google.api.services.vision.v1.model.EntityAnnotation;
import com.google.api.services.vision.v1.model.Status;
import com.google.auto.value.AutoValue;

import java.nio.file.Path;
import java.util.List;
Expand All @@ -28,28 +27,58 @@
/**
* A data object for mapping text to file paths.
*/
@AutoValue
abstract class ImageText {
public class ImageText {
private Path pth;
private List<EntityAnnotation> ts;
private Status err;

public static Builder builder() {
return new AutoValue_ImageText.Builder();
return new Builder();
}

public abstract Path path();
private ImageText() {}

public abstract List<EntityAnnotation> textAnnotations();
public Path path() {
return this.pth;
}

public List<EntityAnnotation> textAnnotations() {
return this.ts;
}

@Nullable
public abstract Status error();
public Status error() {
return this.err;
}

public static class Builder {
private Path pth;
private List<EntityAnnotation> ts;
private Status err;

Builder() {}

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder path(Path path);
public Builder path(Path path) {
this.pth = path;
return this;
}

public abstract Builder textAnnotations(List<EntityAnnotation> ts);
public Builder textAnnotations(List<EntityAnnotation> ts) {
this.ts = ts;
return this;
}

public abstract Builder error(@Nullable Status err);
public Builder error(@Nullable Status err) {
this.err = err;
return this;
}

public abstract ImageText build();
public ImageText build() {
ImageText out = new ImageText();
out.pth = this.pth;
out.ts = this.ts;
out.err = this.err;
return out;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,30 +16,65 @@

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

import com.google.auto.value.AutoValue;

import java.nio.file.Path;

/**
* A data object for mapping words to file paths.
*/
@AutoValue
abstract class Word {
public class Word {
private Path pth;
private String wrd;

public static Builder builder() {
return new AutoValue_Word.Builder();
return new Builder();
}

public Path path() {
return this.pth;
}

public String word() {
return this.wrd;
}

@Override
public boolean equals(Object other) {
if (other == null) {
return false;
}
if (!(other instanceof Word)) {
return false;
}
Word otherWord = (Word) other;
return this.path().equals(otherWord.path()) && this.word().equals(otherWord.word());
}

@Override
public int hashCode() {
return this.word().hashCode() ^ this.path().hashCode();
}

public abstract Path path();
public static class Builder {
private Path pth;
private String wrd;

public abstract String word();
Builder() {}

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder path(Path path);
public Builder path(Path path) {
this.pth = path;
return this;
}

public abstract Builder word(String word);
public Builder word(String word) {
this.wrd = word;
return this;
}

public abstract Word build();
public Word build() {
Word out = new Word();
out.pth = this.pth;
out.wrd = this.wrd;
return out;
}
}
}