ArrayCodecFactory implements CodecFactory { @SuppressWarnings("unchecked") public <T> Codec<T> create(AnnotatedElement metadata, Class<T> type, ResolverContext context) { BoundList settings = null; if (metadata != null && (settings = metadata.getAnnotation(BoundList.class)) != null && type.isArray() && settings.size() != null && settings.size().length() != 0) { Expression<Integer, Resolver> expr = getSizeExpression(settings, context); Codec<Object> elementCodec = null; if (type.getComponentType().isPrimitive()) { elementCodec = (Codec<Object>) factory.create(null, type .getComponentType(), context); } else { BoundObject objectSettings = getObjectSettings(settings); elementCodec = (Codec<Object>) factory.create( new AnnotationWrapper(objectSettings), type .getComponentType(), context); } return (Codec<T>) new ArrayCodec(expr, elementCodec, type); } else { return null; } } ArrayCodecFactory(CodecFactory delegate); @SuppressWarnings("unchecked") Codec<T> create(AnnotatedElement metadata, Class<T> type,
                               ResolverContext context);  }
@Test public void shouldNotTryToReturnCodecInCaseSizeUndefined() { Object array = new byte[0]; Class<?> type = array.getClass(); when(metadata.getAnnotation(BoundList.class)).thenReturn(boundList); when(boundList.size()).thenReturn(""); assertThat(factory.create(metadata, type, context), is(nullValue())); }