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 from one file format to another.
12 public final class Conversion
{
14 private final Document input
;
15 private final String outputMimeType
;
16 private final ConversionOptions options
;
19 * Constructs a conversion with default options.
21 * @param input the input document
22 * @param outputMimeType the output mime type
23 * @throws IllegalArgumentException if the input document is invalid for
26 public Conversion(Document input
, String outputMimeType
) {
27 this(input
, outputMimeType
, ConversionOptions
.Builder
.withDefaults());
31 * Constructs a conversion with specified options.
33 * @param input the input document
34 * @param outputMimeType the output mime type
35 * @param options the conversion options setting
37 public Conversion(Document input
, String outputMimeType
, ConversionOptions options
) {
38 this.input
= Preconditions
.checkNotNull(input
);
39 this.outputMimeType
= Preconditions
.checkNotNull(outputMimeType
).toLowerCase();
40 this.options
= Preconditions
.checkNotNull(options
);
44 * Returns the conversion input document.
46 public Document
getInputDoc() {
51 * Returns the conversion output mime type.
53 public String
getOutputMimeType() {
54 return outputMimeType
;
58 * Returns the conversion options setting.
60 public ConversionOptions
getOptions() {
65 public boolean equals(Object o
) {
69 if (o
== null || getClass() != o
.getClass()) {
73 Conversion other
= (Conversion
) o
;
74 return Objects
.equal(input
, other
.getInputDoc())
75 && Objects
.equal(outputMimeType
, other
.getOutputMimeType())
76 && Objects
.equal(options
, other
.getOptions());
80 public int hashCode() {
81 return Objects
.hashCode(input
, outputMimeType
, options
);