Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / PhoneNumber.java
blob02831f4b1d43e2251087c8555b06c3cebf019bea
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 phone number. No validation is performed because phone
22 * numbers have many different formats - local, long distance, domestic,
23 * international, internal extension, TTY, VOIP, SMS, and alternative networks
24 * like Skype, XFire and Roger Wilco. They all have their own numbering and
25 * addressing formats.
28 public final class PhoneNumber implements Serializable, Comparable<PhoneNumber> {
30 public static final long serialVersionUID = -8968032543663409348L;
32 private String number;
34 public PhoneNumber(String number) {
35 if (number == null) {
36 throw new NullPointerException("number must not be null");
38 this.number = number;
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 PhoneNumber() {
48 number = null;
51 public String getNumber() {
52 return number;
55 @Override
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
60 if (o == null || getClass() != o.getClass()) {
61 return false;
64 PhoneNumber that = (PhoneNumber) o;
66 if (!number.equals(that.number)) {
67 return false;
70 return true;
73 @Override
74 public int hashCode() {
75 return number.hashCode();
78 @Override
79 public int compareTo(PhoneNumber o) {
80 return number.compareTo(o.number);