App Engine Java SDK version 1.9.8
[gae.git] / java / src / main / com / google / appengine / api / datastore / PostalAddress.java
blob62572eafebc7c3eb5d03e68705ba026acf4ccfa4
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 human-readable mailing address. Mailing address formats vary widely so
22 * no validation is performed.
25 public final class PostalAddress implements Serializable, Comparable<PostalAddress> {
27 public static final long serialVersionUID = -1090628591187239495L;
29 private String address;
31 public PostalAddress(String address) {
32 if (address == null) {
33 throw new NullPointerException("address must not be null");
35 this.address = address;
38 /**
39 * This constructor exists for frameworks (e.g. Google Web Toolkit)
40 * that require it for serialization purposes. It should not be
41 * called explicitly.
43 @SuppressWarnings("unused")
44 private PostalAddress() {
45 address = null;
48 public String getAddress() {
49 return address;
52 @Override
53 public boolean equals(Object o) {
54 if (this == o) {
55 return true;
57 if (o == null || getClass() != o.getClass()) {
58 return false;
61 PostalAddress that = (PostalAddress) o;
63 if (!address.equals(that.address)) {
64 return false;
67 return true;
70 @Override
71 public int hashCode() {
72 return address.hashCode();
75 @Override
76 public int compareTo(PostalAddress o) {
77 return address.compareTo(o.address);