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
;
7 import com
.google
.common
.collect
.Lists
;
9 import java
.util
.Collections
;
10 import java
.util
.List
;
13 * An immutable document for conversion. A document must contain at least one
14 * asset, typically the document contents. Additional assets are those needed
15 * for the conversion, for example images in HTML.
18 public final class Document
{
20 private final List
<Asset
> assets
= Lists
.newArrayList();
23 * Constructs a document.
25 * @param firstAsset the first asset to add
27 public Document(Asset firstAsset
) {
28 assets
.add(Preconditions
.checkNotNull(firstAsset
));
32 * Constructs a document.
34 * @param assets a list of assets to add
35 * @throws IllegalArgumentException if the assets list is empty
37 public Document(List
<Asset
> assets
) {
38 Preconditions
.checkNotNull(assets
);
39 Preconditions
.checkArgument(assets
.size() > 0, "The assets list should not be empty");
40 this.assets
.addAll(assets
);
44 * Returns all assets associated with the document.
46 public List
<Asset
> getAssets() {
47 return Collections
.unmodifiableList(assets
);
51 public boolean equals(Object o
) {
55 if (o
== null || getClass() != o
.getClass()) {
59 return Objects
.equal(assets
, ((Document
) o
).getAssets());
63 public int hashCode() {
64 return Objects
.hashCode(assets
);