当前位置: 首页>>代码示例>>Java>>正文


Java CountryCache类代码示例

本文整理汇总了Java中com.helger.commons.locale.country.CountryCache的典型用法代码示例。如果您正苦于以下问题:Java CountryCache类的具体用法?Java CountryCache怎么用?Java CountryCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CountryCache类属于com.helger.commons.locale.country包,在下文中一共展示了CountryCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: VATINStructure

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
public VATINStructure (@Nonnull final String sCountry,
                       @Nonnull @RegEx final String sRegEx,
                       @Nonnull final Collection <String> aExamples)
{
  ValueEnforcer.notNull (sCountry, "Country");
  ValueEnforcer.notNull (sRegEx, "RegEx");
  ValueEnforcer.notEmpty (aExamples, "Example");

  m_aCountry = CountryCache.getInstance ().getCountry (sCountry);
  if (m_aCountry == null)
    throw new IllegalArgumentException ("country");
  m_sPattern = sRegEx;
  m_aPattern = RegExCache.getPattern (sRegEx);
  m_aExamples = new CommonsArrayList <> (aExamples);

  if (GlobalDebug.isDebugMode ())
    for (final String s : m_aExamples)
      if (!isValid (s))
        throw new IllegalArgumentException ("Example VATIN " + s + " does not match " + sRegEx);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:21,代码来源:VATINStructure.java

示例2: getSingleVehicleSign

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Nullable
public static String getSingleVehicleSign (@Nullable final String sCountry)
{
  final Locale aRealCountry = CountryCache.getInstance ().getCountry (sCountry);
  final ICommonsOrderedSet <String> aSigns = s_aCountryToSign.get (aRealCountry);
  if (aSigns != null)
  {
    if (aSigns.size () == 1)
      return aSigns.getFirst ();
    throw new IllegalArgumentException ("Multiple vehicle signs are assigned to the country locale '" +
                                        sCountry +
                                        "': " +
                                        aSigns);
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:17,代码来源:VehicleSigns.java

示例3: testValidity

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Test
public void testValidity ()
{
  final VATManager aVATMgr = VATManager.getDefaultInstance ();
  final Map <String, IVATItem> aData = aVATMgr.getAllVATItemsForCountry (CountryCache.getInstance ()
                                                                                     .getCountry ("hu"));
  assertNotNull (aData);

  IVATItem aItem = aData.get ("hu.v25");
  assertNotNull (aItem);
  assertEquals (BigDecimal.valueOf (25), aItem.getPercentage ());
  assertNull (aItem.getPeriod ().getStart ());
  assertEquals (PDTFactory.createLocalDate (2011, Month.DECEMBER, 31), aItem.getPeriod ().getEnd ());

  aItem = aData.get ("hu.v27");
  assertNotNull (aItem);
  assertEquals (PDTFactory.createLocalDate (2012, Month.JANUARY, 1), aItem.getPeriod ().getStart ());
  assertNull (aItem.getPeriod ().getEnd ());
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:20,代码来源:VATManagerTest.java

示例4: testGetSingleCountryFromVehicleSign

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Test
public void testGetSingleCountryFromVehicleSign ()
{
  final CountryCache aCC = CountryCache.getInstance ();
  assertEquals (aCC.getCountry ("AT"), VehicleSigns.getSingleCountryFromVehicleSign ("A"));
  assertNull (VehicleSigns.getSingleCountryFromVehicleSign ("XYZ"));
  try
  {
    // Has 2 countries
    VehicleSigns.getSingleCountryFromVehicleSign ("ROK");
    fail ();
  }
  catch (final IllegalArgumentException ex)
  {
    // expected
  }
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:18,代码来源:VehicleSignsTest.java

示例5: testDefault

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Test
public void testDefault ()
{
  final DeprecatedLocaleHandler x = DeprecatedLocaleHandler.getDefaultInstance ();
  assertNotNull (x);
  assertEquals (1, x.getAllDeprecatedLocales ().size ());

  // Deprecated one
  assertTrue (x.isDeprecatedLocale (CountryCache.getInstance ().getCountry ("CS")));

  // This locale is only implicitly deprecated
  assertFalse (x.isDeprecatedLocale (LocaleCache.getInstance ().getLocale ("cs", "CS")));

  // This country is not deprecated
  assertFalse (x.isDeprecatedLocale (CountryCache.getInstance ().getCountry ("AT")));

  // Deprecated one with fallback
  assertTrue (x.isDeprecatedLocaleWithFallback (CountryCache.getInstance ().getCountry ("CS")));

  // This locale is implicitly also deprecated
  assertTrue (x.isDeprecatedLocaleWithFallback (LocaleCache.getInstance ().getLocale ("cs", "CS")));

  // This country is not deprecated
  assertFalse (x.isDeprecatedLocaleWithFallback (CountryCache.getInstance ().getCountry ("AT")));
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:26,代码来源:DeprecatedLocaleHandlerTest.java

示例6: cleanup

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
/**
 * Cleanup all custom caches contained in this library. Loaded SPI
 * implementations are not affected by this method!
 */
public static void cleanup ()
{
  // Reinitialize singletons to the default values
  if (LocaleCache.isInstantiated ())
    LocaleCache.getInstance ().reinitialize ();
  if (CountryCache.isInstantiated ())
    CountryCache.getInstance ().reinitialize ();
  if (SerializationConverterRegistry.isInstantiated ())
    SerializationConverterRegistry.getInstance ().reinitialize ();
  if (MimeTypeDeterminator.isInstantiated ())
    MimeTypeDeterminator.getInstance ().reinitialize ();
  if (ThirdPartyModuleRegistry.isInstantiated ())
    ThirdPartyModuleRegistry.getInstance ().reinitialize ();
  if (TypeConverterRegistry.isInstantiated ())
    TypeConverterRegistry.getInstance ().reinitialize ();
  if (URLProtocolRegistry.isInstantiated ())
    URLProtocolRegistry.getInstance ().reinitialize ();
  if (EqualsImplementationRegistry.isInstantiated ())
    EqualsImplementationRegistry.getInstance ().reinitialize ();
  if (HashCodeImplementationRegistry.isInstantiated ())
    HashCodeImplementationRegistry.getInstance ().reinitialize ();

  // Clear caches
  if (DefaultTextResolver.isInstantiated ())
    DefaultTextResolver.getInstance ().clearCache ();
  EnumHelper.clearCache ();
  ResourceBundleHelper.clearCache ();
  if (RegExCache.isInstantiated ())
    RegExCache.getInstance ().clearCache ();
  CollatorHelper.clearCache ();
  LocaleHelper.clearCache ();
  StatisticsManager.clearCache ();
  SystemProperties.clearWarnedPropertyNames ();
  if (ImageDataManager.isInstantiated ())
    ImageDataManager.getInstance ().clearCache ();

  // Clean this one last as it is used in equals and hashCode implementations!
  ClassHierarchyCache.clearCache ();
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:44,代码来源:CommonsCleanup.java

示例7: getVATCountryData

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
/**
 * Get the VAT data of the passed country.
 *
 * @param aLocale
 *        The locale to use. May not be <code>null</code>.
 * @return <code>null</code> if no such country data is present.
 */
@Nullable
public VATCountryData getVATCountryData (@Nonnull final Locale aLocale)
{
  ValueEnforcer.notNull (aLocale, "Locale");
  final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
  return m_aVATItemsPerCountry.get (aCountry);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:15,代码来源:VATManager.java

示例8: VATItem

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
public VATItem (@Nonnull @Nonempty final String sID,
                @Nullable final Locale aCountry,
                @Nonnull final EVATType eType,
                @Nonnull @Nonnegative final BigDecimal aPercentage,
                final boolean bDeprecated,
                @Nullable final LocalDate aValidFrom,
                @Nullable final LocalDate aValidTo)
{
  ValueEnforcer.notEmpty (sID, "ID");
  ValueEnforcer.notNull (eType, "Type");
  ValueEnforcer.notNull (aPercentage, "Percentage");
  ValueEnforcer.isBetweenInclusive (aPercentage, "Percentage", BigDecimal.ZERO, CGlobal.BIGDEC_100);
  // Simply not true
  if (false)
    if (MathHelper.isNE0 (aPercentage))
      ValueEnforcer.notNull (aCountry, "If a percentage is present a country must be present!");
  if (aValidFrom != null && aValidTo != null && aValidTo.isBefore (aValidFrom))
    throw new IllegalArgumentException ("ValidFrom date must be <= validTo date");

  m_sID = sID;
  m_aCountry = CountryCache.getInstance ().getCountry (aCountry);
  m_eType = eType;
  m_aPercentage = aPercentage;
  m_aPercentageFactor = m_aPercentage.divide (CGlobal.BIGDEC_100);
  m_aMultiplicationFactorNetToGross = BigDecimal.ONE.add (m_aPercentageFactor);
  m_bDeprecated = bDeprecated;
  m_aPeriod = new LocalDatePeriod (aValidFrom, aValidTo);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:29,代码来源:VATItem.java

示例9: _add

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
private static void _add (@Nonnull final String sCountryCode, @Nonnull final String sSign)
{
  final Locale aCountry = CountryCache.getInstance ().getCountry (sCountryCode);
  if (s_aCountryToSign.putSingle (aCountry, sSign).isUnchanged ())
    throw new InitializationException ("Locale " + aCountry + " already contains sign '" + sSign + "'");
  if (s_aSignToCountry.putSingle (sSign, aCountry).isUnchanged ())
    throw new InitializationException ("Sign '" + sSign + "' already contains country " + aCountry);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:9,代码来源:VehicleSigns.java

示例10: getAllVehicleSigns

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Nonnull
@ReturnsMutableCopy
public static ICommonsOrderedSet <String> getAllVehicleSigns (@Nullable final String sCountry)
{
  final Locale aRealCountry = CountryCache.getInstance ().getCountry (sCountry);
  final ICommonsOrderedSet <String> aSigns = s_aCountryToSign.get (aRealCountry);
  return new CommonsLinkedHashSet <> (aSigns);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:9,代码来源:VehicleSigns.java

示例11: getContinentsOfCountry

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
/**
 * Get all continents for the specified country ID
 *
 * @param aLocale
 *        The locale to be used. May be <code>null</code>.
 * @return <code>null</code> if no continent data is defined. Otherwise a non-
 *         <code>null</code> Set with all continents, without
 *         <code>null</code> elements.
 */
@Nullable
@ReturnsMutableCopy
public static ICommonsNavigableSet <EContinent> getContinentsOfCountry (@Nullable final Locale aLocale)
{
  final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
  if (aCountry != null)
  {
    final ICommonsNavigableSet <EContinent> ret = s_aMap.get (aCountry);
    if (ret != null)
      return ret.getClone ();
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:23,代码来源:ContinentHelper.java

示例12: addCountry

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
public void addCountry (@Nonnull final IPostalCodeCountry aPostalCountry)
{
  ValueEnforcer.notNull (aPostalCountry, "PostalCountry");

  // Unify ISO code
  final Locale aCountry = CountryCache.getInstance ().getCountry (aPostalCountry.getISO ());

  m_aRWLock.writeLocked ( () -> {
    if (m_aMap.containsKey (aCountry))
      throw new IllegalArgumentException ("A country with code '" + aCountry + "' was already regsitered!");
    m_aMap.put (aCountry, aPostalCountry);
  });
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:14,代码来源:PostalCodeManager.java

示例13: getCountryLocale

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Nullable
public Locale getCountryLocale ()
{
  Locale ret = m_aCountry;
  if (ret == null && m_sCountry != null)
  {
    m_aCountry = ret = CountryCache.getInstance ().getCountry (m_sCountry);
  }
  return ret;
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:11,代码来源:PostalAddress.java

示例14: testGetFromCountry

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Test
public void testGetFromCountry ()
{
  // The following countries have multiple currencies:
  final Locale aLocCuba = CountryCache.getInstance ().getCountry ("CU");

  for (final ECurrency e : ECurrency.values ())
    if (!e.isDeprecated ())
      for (final Locale aLocale : e.getAllMatchingLocales ())
        if (!EqualsHelper.equals (aLocale, aLocCuba))
          assertSame (e, ECurrency.getFromLocaleOrNull (aLocale));
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:13,代码来源:ECurrencyTest.java

示例15: testGetAllCountriesFromVehicleSign

import com.helger.commons.locale.country.CountryCache; //导入依赖的package包/类
@Test
public void testGetAllCountriesFromVehicleSign ()
{
  final CountryCache aCC = CountryCache.getInstance ();
  assertEquals (new CommonsLinkedHashSet <> (aCC.getCountry ("AT")),
                VehicleSigns.getAllCountriesFromVehicleSign ("A"));
  assertEquals (new CommonsLinkedHashSet <> (), VehicleSigns.getAllCountriesFromVehicleSign ("XYZ"));
  // Has 2 countries
  assertEquals (new CommonsLinkedHashSet <> (aCC.getCountry ("KP"), aCC.getCountry ("KR")),
                VehicleSigns.getAllCountriesFromVehicleSign ("ROK"));
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:12,代码来源:VehicleSignsTest.java


注:本文中的com.helger.commons.locale.country.CountryCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。