App Engine Python SDK version 1.8.4
[gae.git] / java / src / main / com / google / appengine / api / conversion / Conversion.java
blob645002006847f67edf39a4e26f39c3723acc7854
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;
8 /**
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;
18 /**
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
24 * conversion
26 public Conversion(Document input, String outputMimeType) {
27 this(input, outputMimeType, ConversionOptions.Builder.withDefaults());
30 /**
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);
43 /**
44 * Returns the conversion input document.
46 public Document getInputDoc() {
47 return input;
50 /**
51 * Returns the conversion output mime type.
53 public String getOutputMimeType() {
54 return outputMimeType;
57 /**
58 * Returns the conversion options setting.
60 public ConversionOptions getOptions() {
61 return options;
64 @Override
65 public boolean equals(Object o) {
66 if (this == o) {
67 return true;
69 if (o == null || getClass() != o.getClass()) {
70 return false;
73 Conversion other = (Conversion) o;
74 return Objects.equal(input, other.getInputDoc())
75 && Objects.equal(outputMimeType, other.getOutputMimeType())
76 && Objects.equal(options, other.getOptions());
79 @Override
80 public int hashCode() {
81 return Objects.hashCode(input, outputMimeType, options);