1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.conversion
;
5 import com
.google
.common
.base
.Objects
;
6 import com
.google
.common
.base
.Preconditions
;
9 * A single immutable conversion result returned by the conversion service.
12 public final class ConversionResult
{
13 private final ConversionErrorCode errorCode
; private final Document output
;
16 * Constructs a conversion result when the conversion failed.
18 * @param errorCode the conversion error code
20 ConversionResult(ConversionErrorCode errorCode
) {
21 this.errorCode
= Preconditions
.checkNotNull(errorCode
);
26 * Constructs a conversion result when the conversion succeeded.
28 * @param output the output document
30 ConversionResult(Document output
) {
31 this.errorCode
= null;
32 this.output
= Preconditions
.checkNotNull(output
);
36 * Returns whether the conversion succeeded.
38 public boolean success() {
39 return output
!= null;
43 * Returns the conversion error code, or null if the conversion succeeded.
45 public ConversionErrorCode
getErrorCode() {
50 * Returns the conversion output document, or null if the conversion failed.
52 public Document
getOutputDoc() {
57 public boolean equals(Object o
) {
61 if (o
== null || getClass() != o
.getClass()) {
65 ConversionResult other
= (ConversionResult
) o
;
66 return Objects
.equal(errorCode
, other
.getErrorCode())
67 && Objects
.equal(output
, other
.getOutputDoc());
71 public int hashCode() {
72 return Objects
.hashCode(errorCode
, output
);