@Test
 public void shouldCreateWithDefaults() throws Exception {
   ConcurrentReferenceHashMap<Integer, String> map =
       new ConcurrentReferenceHashMap<Integer, String>();
   assertThat(map.getSegmentsSize(), is(16));
   assertThat(map.getSegment(0).getSize(), is(1));
   assertThat(map.getLoadFactor(), is(0.75f));
 }
 @Test
 public void shouldCreateWithInitialCapacityAndConcurrenyLevel() throws Exception {
   ConcurrentReferenceHashMap<Integer, String> map =
       new ConcurrentReferenceHashMap<Integer, String>(16, 2);
   assertThat(map.getSegmentsSize(), is(2));
   assertThat(map.getSegment(0).getSize(), is(8));
   assertThat(map.getLoadFactor(), is(0.75f));
 }
 @Test
 public void shouldCreateFullyCustom() throws Exception {
   ConcurrentReferenceHashMap<Integer, String> map =
       new ConcurrentReferenceHashMap<Integer, String>(5, 0.5f, 3);
   // concurrencyLevel of 3 ends up as 4 (nearest power of 2)
   assertThat(map.getSegmentsSize(), is(4));
   // initialCapacity is 5/4 (rounded up, to nearest power of 2)
   assertThat(map.getSegment(0).getSize(), is(2));
   assertThat(map.getLoadFactor(), is(0.5f));
 }
 /** Return a {@link Serializable} {@link Type} backed by a {@link TypeProvider} . */
 static Type forTypeProvider(final TypeProvider provider) {
   Assert.notNull(provider, "Provider must not be null");
   if (provider.getType() instanceof Serializable || provider.getType() == null) {
     return provider.getType();
   }
   Type cached = cache.get(provider.getType());
   if (cached != null) {
     return cached;
   }
   for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {
     if (type.isAssignableFrom(provider.getType().getClass())) {
       ClassLoader classLoader = provider.getClass().getClassLoader();
       Class<?>[] interfaces =
           new Class<?>[] {type, SerializableTypeProxy.class, Serializable.class};
       InvocationHandler handler = new TypeProxyInvocationHandler(provider);
       cached = (Type) Proxy.newProxyInstance(classLoader, interfaces, handler);
       cache.put(provider.getType(), cached);
       return cached;
     }
   }
   throw new IllegalArgumentException(
       "Unsupported Type class " + provider.getType().getClass().getName());
 }