public CodecSelector create(ResolverContext context,
List<Codec<?>> allCodecs) {
int size = -1;
List<Expression<Integer, Resolver>> expressions = new ArrayList<Expression<Integer, Resolver>>();
List<Codec<?>> codecs = new ArrayList<Codec<?>>();
ByteOrder byteOrder = null;
for (Codec<?> codec : allCodecs) {
for (Class<?> valueType : codec.getTypes()) {
TypePrefix prefix = (TypePrefix) valueType
.getAnnotation(TypePrefix.class);
if (prefix == null) {
throw new CodecConstructionException(
"To little context to decide between codecs.");
} else {
if (byteOrder == null) {
byteOrder = prefix.byteOrder();
} else {
if (byteOrder != prefix.byteOrder()) {
throw new CodecConstructionException("Two distinct types of byte orders are not supported: "
+ "expected " + byteOrder.asText() + ", got "
+ prefix.byteOrder().asText() + " for " + codec);
}
}
if (size != -1) {
if (size != prefix.size()) {