@SuppressWarnings("unchecked") private static List<RegistrationBlock> buildRegistrationBlocks(NamespaceConfig config) { List<Pair<Class<?>[], Serializer<?>>> types = new ArrayList<>(); List<RegistrationBlock> blocks = new ArrayList<>(); blocks.addAll(Namespaces.BASIC.registeredBlocks); for (NamespaceTypeConfig type : config.getTypes()) { try { if (type.getId() == null) { types.add(Pair.of(new Class[]{type.getType()}, type.getSerializer() != null ? type.getSerializer().newInstance() : null)); } else { blocks.add(new RegistrationBlock(type.getId(), Collections.singletonList(Pair.of(new Class[]{type.getType()}, type.getSerializer().newInstance())))); } } catch (InstantiationException | IllegalAccessException e) { throw new ConfigurationException("Failed to instantiate serializer from configuration", e); } } blocks.add(new RegistrationBlock(FLOATING_ID, types)); return blocks; }
@SuppressWarnings("unchecked") private static List<RegistrationBlock> buildRegistrationBlocks(NamespaceConfig config) { List<Pair<Class<?>[], Serializer<?>>> types = new ArrayList<>(); List<RegistrationBlock> blocks = new ArrayList<>(); blocks.addAll(Namespaces.BASIC.registeredBlocks); for (NamespaceTypeConfig type : config.getTypes()) { try { if (type.getId() == null) { types.add(Pair.of(new Class[]{type.getType()}, type.getSerializer() != null ? type.getSerializer().newInstance() : null)); } else { blocks.add(new RegistrationBlock(type.getId(), Collections.singletonList(Pair.of(new Class[]{type.getType()}, type.getSerializer().newInstance())))); } } catch (InstantiationException | IllegalAccessException e) { throw new ConfigurationException("Failed to instantiate serializer from configuration", e); } } blocks.add(new RegistrationBlock(FLOATING_ID, types)); return blocks; }