Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / libaddressinput / src / java / src / com / android / i18n / addressinput / StandardChecks.java
1 /*
2  * Copyright (C) 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.android.i18n.addressinput;
18
19 import java.util.Arrays;
20 import java.util.Collections;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 /**
26  * Loader for a map defining the standard checks to perform on AddressFields.
27  */
28 public class StandardChecks {
29
30   private StandardChecks() {
31   }
32
33   public static final Map<AddressField, List<AddressProblemType>> PROBLEM_MAP;
34
35   static {
36     Map<AddressField, List<AddressProblemType>> map =
37         new HashMap<AddressField, List<AddressProblemType>>();
38
39     addToMap(map, AddressField.COUNTRY, AddressProblemType.USING_UNUSED_FIELD,
40         AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
41     addToMap(map, AddressField.ADMIN_AREA, AddressProblemType.USING_UNUSED_FIELD,
42         AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
43     addToMap(map, AddressField.LOCALITY, AddressProblemType.USING_UNUSED_FIELD,
44         AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
45     addToMap(map, AddressField.DEPENDENT_LOCALITY, AddressProblemType.USING_UNUSED_FIELD,
46         AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
47     addToMap(map, AddressField.POSTAL_CODE, AddressProblemType.USING_UNUSED_FIELD,
48         AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNRECOGNIZED_FORMAT,
49         AddressProblemType.MISMATCHING_VALUE);
50     addToMap(map, AddressField.STREET_ADDRESS, AddressProblemType.USING_UNUSED_FIELD,
51         AddressProblemType.MISSING_REQUIRED_FIELD);
52     addToMap(map, AddressField.SORTING_CODE, AddressProblemType.USING_UNUSED_FIELD,
53         AddressProblemType.MISSING_REQUIRED_FIELD);
54     addToMap(map, AddressField.ORGANIZATION, AddressProblemType.USING_UNUSED_FIELD,
55         AddressProblemType.MISSING_REQUIRED_FIELD);
56     addToMap(map, AddressField.RECIPIENT, AddressProblemType.USING_UNUSED_FIELD,
57         AddressProblemType.MISSING_REQUIRED_FIELD);
58
59     PROBLEM_MAP = Collections.unmodifiableMap(map);
60   }
61
62   private static void addToMap(Map<AddressField, List<AddressProblemType>> map,
63       AddressField field,
64       AddressProblemType... problems) {
65     map.put(field, Collections.unmodifiableList(Arrays.asList(problems)));
66   }
67 }