commit
						771a98b192
					
				| 
						 | 
					@ -39,31 +39,22 @@ import org.springframework.boot.origin.Origin;
 | 
				
			||||||
class ConfigDataLocationBindHandler extends AbstractBindHandler {
 | 
					class ConfigDataLocationBindHandler extends AbstractBindHandler {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	@SuppressWarnings("unchecked")
 | 
					 | 
				
			||||||
	public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) {
 | 
						public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) {
 | 
				
			||||||
		if (result instanceof ConfigDataLocation location) {
 | 
							if (result instanceof ConfigDataLocation location) {
 | 
				
			||||||
			return withOrigin(context, location);
 | 
								return withOrigin(context, location);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (result instanceof List) {
 | 
							if (result instanceof List<?> list) {
 | 
				
			||||||
			List<Object> list = ((List<Object>) result).stream()
 | 
								return list.stream()
 | 
				
			||||||
				.filter(Objects::nonNull)
 | 
									.filter(Objects::nonNull)
 | 
				
			||||||
 | 
									.map((element) -> (element instanceof ConfigDataLocation location) ? withOrigin(context, location)
 | 
				
			||||||
 | 
											: element)
 | 
				
			||||||
				.collect(Collectors.toCollection(ArrayList::new));
 | 
									.collect(Collectors.toCollection(ArrayList::new));
 | 
				
			||||||
			for (int i = 0; i < list.size(); i++) {
 | 
					 | 
				
			||||||
				Object element = list.get(i);
 | 
					 | 
				
			||||||
				if (element instanceof ConfigDataLocation location) {
 | 
					 | 
				
			||||||
					list.set(i, withOrigin(context, location));
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return list;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (result instanceof ConfigDataLocation[] unfilteredLocations) {
 | 
							if (result instanceof ConfigDataLocation[] unfilteredLocations) {
 | 
				
			||||||
			ConfigDataLocation[] locations = Arrays.stream(unfilteredLocations)
 | 
								return Arrays.stream(unfilteredLocations)
 | 
				
			||||||
				.filter(Objects::nonNull)
 | 
									.filter(Objects::nonNull)
 | 
				
			||||||
 | 
									.map((element) -> withOrigin(context, element))
 | 
				
			||||||
				.toArray(ConfigDataLocation[]::new);
 | 
									.toArray(ConfigDataLocation[]::new);
 | 
				
			||||||
			for (int i = 0; i < locations.length; i++) {
 | 
					 | 
				
			||||||
				locations[i] = withOrigin(context, locations[i]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return locations;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return result;
 | 
							return result;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue