Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / Category.java
blob6bf335ddccfeb5e6d8e37a622b92eff0e4163e95
1 /*
2 * Copyright 2009 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
16 package com.google.appengine.api.datastore;
18 import java.io.Serializable;
20 /**
21 * A tag, ie a descriptive word or phrase. Entities may be tagged by users,
22 * and later returned by a queries for that tag. Tags can also be used for
23 * ranking results (frequency), photo captions, clustering, activity, etc.
25 * @see <a href="http://www.zeldman.com/daily/0405d.shtml">Jeffrey Zeldmans blog post</a>
26 * on tag clouds for a more in-depth description.
28 public final class Category implements Serializable, Comparable<Category> {
30 public static final long serialVersionUID = 8556134984576082397L;
32 private String category;
34 public Category(String category) {
35 if (category == null) {
36 throw new NullPointerException("category must not be null");
38 this.category = category;
41 /**
42 * This constructor exists for frameworks (e.g. Google Web Toolkit)
43 * that require it for serialization purposes. It should not be
44 * called explicitly.
46 @SuppressWarnings("unused")
47 private Category() {
48 this.category = null;
51 public String getCategory() {
52 return category;
55 @Override
56 public int compareTo(Category o) {
57 return category.compareTo(o.category);
60 @Override
61 public boolean equals(Object o) {
62 if (this == o) {
63 return true;
65 if (o == null || getClass() != o.getClass()) {
66 return false;
69 Category category1 = (Category) o;
71 if (!category.equals(category1.category)) {
72 return false;
75 return true;
78 @Override
79 public int hashCode() {
80 return category.hashCode();