本文整理汇总了Java中com.neovisionaries.i18n.CountryCode.getByCode方法的典型用法代码示例。如果您正苦于以下问题:Java CountryCode.getByCode方法的具体用法?Java CountryCode.getByCode怎么用?Java CountryCode.getByCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.neovisionaries.i18n.CountryCode
的用法示例。
在下文中一共展示了CountryCode.getByCode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shippingAddress
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
@Override
public Address shippingAddress() {
final CountryCode country = CountryCode.getByCode(countryShipping);
return AddressBuilder.of(country)
.title(titleShipping)
.firstName(firstNameShipping)
.lastName(lastNameShipping)
.streetName(streetNameShipping)
.additionalStreetInfo(additionalStreetInfoShipping)
.city(cityShipping)
.postalCode(postalCodeShipping)
.region(regionShipping)
.phone(phoneShipping)
.email(emailShipping)
.build();
}
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:17,代码来源:DefaultCheckoutAddressFormData.java
示例2: billingAddress
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
@Override
@Nullable
public Address billingAddress() {
if (billingAddressDifferentToBillingAddress) {
final CountryCode country = CountryCode.getByCode(countryBilling);
return AddressBuilder.of(country)
.title(titleBilling)
.firstName(firstNameBilling)
.lastName(lastNameBilling)
.streetName(streetNameBilling)
.additionalStreetInfo(additionalStreetInfoBilling)
.city(cityBilling)
.postalCode(postalCodeBilling)
.region(regionBilling)
.phone(phoneBilling)
.email(emailBilling)
.build();
} else {
return null;
}
}
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:22,代码来源:DefaultCheckoutAddressFormData.java
示例3: setCountryCode
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
public void setCountryCode(String countryCode) throws InvalidCountryCode {
CountryCode cc = CountryCode.getByCode(countryCode);
if(cc == null) {
// There is a chance it came in as United States for example.
List<CountryCode> results = CountryCode.findByName(countryCode);
if(results.size() < 1 || results.size() > 1) {
throw new InvalidCountryCode("Invalid Country Code detected: " + countryCode);
}
cc = results.get(0);
}
if(cc.toString().length() != 2) {
throw new InvalidCountryCode("Invalid Country Code detected: " + countryCode);
}
this.countryCode = cc.toString();
}
示例4: getInseeWithAlpha3
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
@Override
protected String getInseeWithAlpha3(String alpha3) {
String alpha32 = alpha3;
if (CountryCode.getByCode(alpha3) == null) {
alpha32 = alpha3.substring(0, alpha3.length() - 1);
}
return CountryCode.getByCode(alpha32) == null ? alpha3 : valueOf(CountryCode.getByCode(alpha32).getNumeric());
}
示例5: getCountry
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
@Override
public String getCountry() {
CountryCode countryCode = CountryCode.getByCode(country);
if (countryCode == null) {
return country;
}
else {
return countryCode.getName();
}
}
示例6: lookup
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
/**
* Look up a {@link CountryCode} instance from an ISO 3166-1 code.
*
* @param code
* ISO 3166-1 code (alpha-2, alpha-3, or numeric).
*
* @return
* A {@link CountryCode} instance that corresponds to the
* given code. If the given code is not valid, {@code null}
* is returned.
*/
private CountryCode lookup(String code)
{
if (code == null)
{
// Not found.
return null;
}
// Interpret the code as an ISO 3166-1 alpha-2 or alpha-3 code.
CountryCode cc = CountryCode.getByCodeIgnoreCase(code);
if (cc != null)
{
// Found.
return cc;
}
try
{
// Interpret the code as an ISO 3166-1 numeric code.
return CountryCode.getByCode(Integer.parseInt(code));
}
catch (NumberFormatException e)
{
// Not found.
return null;
}
}
示例7: validate
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
public String validate() {
final CountryCode country = CountryCode.getByCode(this.country);
if (country == null || country.equals(CountryCode.UNDEFINED)) {
return "Invalid country"; // TODO use i18n version
}
return null;
}
示例8: address
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
@Override
public Address address() {
final CountryCode countryCode = CountryCode.getByCode(country);
return AddressBuilder.of(countryCode)
.title(title)
.firstName(firstName)
.lastName(lastName)
.streetName(streetName)
.additionalStreetInfo(additionalStreetInfo)
.city(city)
.postalCode(postalCode)
.region(region)
.build();
}
示例9: validate
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
public String validate() {
final CountryCode shippingCountry = CountryCode.getByCode(countryShipping);
if (shippingCountry == null || shippingCountry.equals(CountryCode.UNDEFINED)) {
return "Invalid shipping country"; // TODO use i18n version
}
if (billingAddressDifferentToBillingAddress) {
final CountryCode billingCountry = CountryCode.getByCode(countryBilling);
if (billingCountry == null || billingCountry.equals(CountryCode.UNDEFINED)) {
return "Invalid billing country"; // TODO use i18n version
}
}
return null;
}
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:14,代码来源:DefaultCheckoutAddressFormData.java
示例10: alpha3toAlpha2
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
public static String alpha3toAlpha2(String alpha3) throws UnknownCountryException {
if(alpha3.length()==0) return " ";
CountryCode countryCode = CountryCode.getByCode(alpha3);
if(null==countryCode){
throw new UnknownCountryException("Can't find country "+alpha3, alpha3);
}
return countryCode.getAlpha2();
}
示例11: getFlagResource
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
public static int getFlagResource( final String countryCode )
{
int resourceId = R.drawable.flag_unknown;
if( countryCode != null && countryCode.trim().length() > 0 )
{
CountryCode cc = CountryCode.getByCode( countryCode, false );
if( cc != null )
{
resourceId = s_codeToFlag.get( cc.getAlpha3() );
}
}
return resourceId;
}
示例12: fillList
import com.neovisionaries.i18n.CountryCode; //导入方法依赖的package包/类
protected void fillList(final CountryFormFieldViewModel viewModel, final FormFieldWithOptions<CountryCode> formFieldWithOptions) {
final CountryCode selectedCountry = CountryCode.getByCode(formFieldWithOptions.getFormField().value());
viewModel.setList(formFieldWithOptions.getFormOptions().stream()
.map(country -> countryFormSelectableOptionViewModelFactory.create(country, selectedCountry))
.collect(toList()));
}
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:7,代码来源:CountryFormFieldViewModelFactory.java