/** * As {@link LocationRegistry#getListOfLocationsManaged(Object)}, * but using {@link #coerceToLocationManaged(ManagementContext, Object)} * for more forgiving interpretations. * <p> * The caller is responsible for ensuring the resulting {@link Location} is unmanaged. */ public static Collection<? extends Location> coerceToCollectionOfLocationsManaged(ManagementContext mgmt, Object rawO) { if (rawO==null) return null; Object raw = rawO; if (raw instanceof Collection) { List<Location> result = MutableList.<Location>of(); for (Object o: (Collection<?>)raw) result.add(coerceToLocationManaged(mgmt, o)); return result; } if (raw instanceof String) { raw = Yamls.parseAll((String)raw).iterator().next(); if (raw instanceof Collection) return Locations.coerceToCollectionOfLocationsManaged(mgmt, raw); } return Collections.singletonList( coerceToLocationManaged(mgmt, raw) ); } }
@Override public Void call(ConfigBag parameters) { Collection<? extends Location> locations = null; Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollectionOfLocationsManaged(entity().getManagementContext(), locationsRaw); if (locations == null) { // null/empty will mean to inherit from parent locations = Collections.emptyList(); } start(locations); return null; }
@Override public Void call(ConfigBag parameters) { Collection<? extends Location> locations = null; Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollectionOfLocationsManaged(entity().getManagementContext(), locationsRaw); if (locations==null) { // null/empty will mean to inherit from parent locations = Collections.emptyList(); } start(locations); return null; } };