001/*
002 * oauth2-oidc-sdk
003 *
004 * Copyright 2012-2016, Connect2id Ltd and contributors.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
007 * this file except in compliance with the License. You may obtain a copy of the
008 * License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed
013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
015 * specific language governing permissions and limitations under the License.
016 */
017
018package com.nimbusds.openid.connect.sdk.assurance.claims;
019
020
021import com.nimbusds.oauth2.sdk.ParseException;
022import com.nimbusds.oauth2.sdk.id.Identifier;
023
024
025/**
026 * Abstract class for country codes.
027 */
028public abstract class CountryCode extends Identifier {
029        
030        
031        private static final long serialVersionUID = -6171424661935191539L;
032        
033        
034        /**
035         * Creates a new country code.
036         *
037         * @param value The country code value.
038         */
039        protected CountryCode(final String value) {
040                super(value);
041        }
042        
043        
044        /**
045         * Casts this code to an ISO 3166-1 alpha-2 (two-letter) country code.
046         *
047         * @return The ISO 3166-1 alpha-2 (two-letter) country code.
048         */
049        public ISO3166_1Alpha2CountryCode toISO3166_1Alpha2CountryCode() {
050                
051                return (ISO3166_1Alpha2CountryCode)this;
052        }
053        
054        
055        /**
056         * Parses a country code.
057         *
058         * @param s The string to parse. Must not be {@code null}.
059         *
060         * @return The country code.
061         *
062         * @throws ParseException If parsing failed.
063         */
064        public static CountryCode parse(final String s)
065                throws ParseException {
066                
067                return ISO3166_1Alpha2CountryCode.parse(s);
068        }
069        
070        
071        @Override
072        public abstract boolean equals(final Object other);
073}