| 91 | } |
| 92 | |
| 93 | public static Registry<String, ? extends Parameter<?>> replace(Registry<String, ? extends Parameter<?>> registry, Parameter<?> param) { |
| 94 | Assert.notEmpty(registry, "Registry cannot be null or empty."); |
| 95 | Assert.notNull(param, "Parameter cannot be null."); |
| 96 | String id = Assert.hasText(param.getId(), "Parameter id cannot be null or empty."); |
| 97 | Map<String, Parameter<?>> newParams = new LinkedHashMap<>(registry); |
| 98 | newParams.remove(id); // remove old/default |
| 99 | newParams.put(id, param); // add new one |
| 100 | return registry(newParams.values()); |
| 101 | } |
| 102 | |
| 103 | private static byte[] bytes(BigInteger i) { |
| 104 | return i != null ? i.toByteArray() : null; |