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 * An immutable asset for conversion. A conversion document must contain at
10 * least one asset, typically the document contents. Additional asset can be
11 * referenced from the main asset, such as in case of images or CSS files from
15 public final class Asset
{
17 private final String mimeType
;
18 private final byte[] data
; private final String name
;
21 * Constructs an asset.
23 * @param mimeType the asset's mime type
24 * @param data the asset's data
26 public Asset(String mimeType
, byte[] data
) {
27 this(mimeType
, data
, null);
31 * Constructs an asset.
33 * @param mimeType the asset's mime type
34 * @param data the asset's data
35 * @param name the asset's name, or null if none
37 public Asset(String mimeType
, byte[] data
, String name
) {
38 this.mimeType
= Preconditions
.checkNotNull(mimeType
).toLowerCase();
44 * Returns the asset's mime type.
46 public String
getMimeType() {
51 * Returns the asset's data.
53 public byte[] getData() {
58 * Returns the asset's name, or null if not present.
60 public String
getName() {
65 public boolean equals(Object o
) {
69 if (o
== null || getClass() != o
.getClass()) {
73 Asset other
= ((Asset
) o
);
74 return Objects
.equal(mimeType
, other
.getMimeType())
75 && Objects
.deepEquals(data
, other
.getData())
76 && Objects
.equal(name
, other
.getName());
80 public int hashCode() {
81 return Objects
.hashCode(mimeType
, data
, name
);