Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / Email.java
blobe5ed687f77bfe20485b97b3a8c88fa24b0992135
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 * An e-mail address datatype. Makes no attempt at validation.
23 * @see <a href="http://tools.ietf.org/html/rfc2822">RFC 2822</a>
24 * for the e-mail address specification.
26 public final class Email implements Serializable, Comparable<Email> {
27 static final long serialVersionUID = -4807513785819575482L;
29 private String email;
31 public Email(String email) {
32 if (email == null) {
33 throw new NullPointerException("email must not be null");
35 this.email = email;
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 Email() {
45 this.email = null;
48 public String getEmail() {
49 return email;
52 @Override
53 public int compareTo(Email e) {
54 return email.compareTo(e.email);
57 @Override
58 public boolean equals(Object o) {
59 if (this == o) {
60 return true;
62 if (o == null || getClass() != o.getClass()) {
63 return false;
66 Email email1 = (Email) o;
68 if (!email.equals(email1.email)) {
69 return false;
72 return true;
75 @Override
76 public int hashCode() {
77 return email.hashCode();