App Engine Python SDK version 1.8.4
[gae.git] / java / src / main / com / google / appengine / api / conversion / Document.java
blob15b1f9eb075164022ad84ec0ff4962b59158b326
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;
12 /**
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();
22 /**
23 * Constructs a document.
25 * @param firstAsset the first asset to add
27 public Document(Asset firstAsset) {
28 assets.add(Preconditions.checkNotNull(firstAsset));
31 /**
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);
43 /**
44 * Returns all assets associated with the document.
46 public List<Asset> getAssets() {
47 return Collections.unmodifiableList(assets);
50 @Override
51 public boolean equals(Object o) {
52 if (this == o) {
53 return true;
55 if (o == null || getClass() != o.getClass()) {
56 return false;
59 return Objects.equal(assets, ((Document) o).getAssets());
62 @Override
63 public int hashCode() {
64 return Objects.hashCode(assets);