use of org.springframework.tuple.TupleBuilder in project spring-cloud-gateway by spring-cloud.
the class RouteDefinitionRouteLocator method getTuple.
@SuppressWarnings("Duplicates")
// TODO: remove after Tuple is removed
@Deprecated
static /* for testing */
Tuple getTuple(ShortcutConfigurable shortcutConf, Map<String, String> args, SpelExpressionParser parser, BeanFactory beanFactory) {
TupleBuilder builder = TupleBuilder.tuple();
List<String> argNames = shortcutConf.shortcutFieldOrder();
if (!argNames.isEmpty()) {
// ensure size is the same for key replacement later
if (shortcutConf.validateFieldsExist() && args.size() != argNames.size()) {
throw new IllegalArgumentException("Wrong number of arguments. Expected " + argNames + " " + argNames + ". Found " + args.size() + " " + args + "'");
}
}
int entryIdx = 0;
for (Map.Entry<String, String> entry : args.entrySet()) {
String key = normalizeKey(entry.getKey(), entryIdx, shortcutConf, args);
Object value = getValue(parser, beanFactory, entry.getValue());
builder.put(key, value);
entryIdx++;
}
Tuple tuple = builder.build();
if (shortcutConf.validateFieldsExist()) {
for (String name : argNames) {
if (!tuple.hasFieldName(name)) {
throw new IllegalArgumentException("Missing argument '" + name + "'. Given " + tuple);
}
}
}
return tuple;
}
Aggregations