Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / Link.java
blob17bd1518039df8ec29d340f7aeb4e14909aaae95
1 /*
2 * Copyright 2008 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 {@code Link} is a URL of limited length.
23 * In addition to adding the meaning of {@code URL} onto a String, a {@code Link}
24 * can also be longer than a Text value, with a limit of 2083 characters.
27 public final class Link implements Serializable, Comparable<Link> {
29 public static final long serialVersionUID = 731239796613544443L;
31 private String value;
33 /**
34 * This constructor exists for frameworks (e.g. Google Web Toolkit)
35 * that require it for serialization purposes. It should not be
36 * called explicitly.
38 @SuppressWarnings("unused")
39 private Link() {
40 value = null;
43 /**
44 * Constructs a new {@code Link} object with the specified value.
45 * This object cannot be modified after construction.
47 public Link(String value) {
48 this.value = value;
51 /**
52 * Returns the value of this {@code Link}.
54 public String getValue() {
55 return value;
58 @Override
59 public int hashCode() {
60 return value.hashCode();
63 /**
64 * Two {@code Link} objects are considered equal if their content
65 * strings match exactly.
67 @Override
68 public boolean equals(Object object) {
69 if (object instanceof Link) {
70 Link key = (Link) object;
71 return value.equals(key.value);
73 return false;
76 /**
77 * Returns the entire text of this {@code Link}.
79 @Override
80 public String toString() {
81 return value;
84 @Override
85 public int compareTo(Link l) {
86 return value.compareTo(l.value);