forked from google/gdata-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegionCodeValueConstruct.java
More file actions
81 lines (70 loc) · 2.29 KB
/
Copy pathRegionCodeValueConstruct.java
File metadata and controls
81 lines (70 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Copyright (c) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gdata.data.webmastertools;
import com.google.gdata.data.ValueConstruct;
/**
* GData schema extension describing a node with a region code value.
* This class is abstract, derive from this class and define a default
* constructor which has the node name hardcoded, see
* http://www.unicode.org/cldr/data/diff/supplemental/territory_containment_un_m_49.html
* for a list of valid region codes.
*
*
*/
public abstract class RegionCodeValueConstruct extends ValueConstruct {
/**
* Default value for the region code is US
*/
public static final String DEFAULT_REGION_CODE = "ZZ";
/**
* Constructs {@link ValueConstruct} to represent the region code value.
*/
public RegionCodeValueConstruct(String nodeName) {
super(Namespaces.WT_NAMESPACE, nodeName, null);
setValue(DEFAULT_REGION_CODE);
}
/**
* Compares {@link RegionCodeValueConstruct} objects based on the region code
* value that they hold.
*/
@Override
public boolean equals(Object rhs) {
if (!super.equals(rhs)) {
return false;
}
return getValue().equals(((RegionCodeValueConstruct) rhs).getValue());
}
/**
* Returns hash code which is based on the Region Code string representation.
*/
@Override
public int hashCode() {
return getValue().hashCode();
}
/**
* Override {@link ValueConstruct#setValue(String)} to validate that
* the region code is not null.
*
* @throws NullPointerException if the value is null.
*/
@Override
public void setValue(String value)
throws NullPointerException, IllegalArgumentException{
if (value == null) {
throw new NullPointerException("value cannot be null");
}
super.setValue(value);
}
}