/** * Returns the device represented by a first segment. * @param path Path to check. * @return The resolved device or {@code null} if no device is found. */ public final Device findDeviceByFirstSegment(PathSegments path) { if (path == null || path.isEmpty()) { return null; } return findDeviceByFirstSegment(path.get(0)); }
public ResolvedDevice resolveDevice(DeviceResolutionParams params) { final Portal portal = params.getPortal(); final PathSegments path = params.getPath(); DevicesInPortal dips = portal.getDevices(); if (config != null && !config.includeDefault()) { dips = dips.excludeDevice(portal.getDevice()); } final Device d = portal.getDevices().findDeviceByFirstSegment(path); if (d != null) { return new ResolvedDevice(path.consume(), d, new DefaultDeviceCapabilities(d), params.getParameters()); } return null; } }
/** * @see com.isotrol.impe3.api.DeviceResolver#resolveDevice(com.isotrol.impe3.api.DeviceResolutionParams) */ public ResolvedDevice resolveDevice(DeviceResolutionParams params) { final DevicesInPortal dips = params.getPortal().getDevices(); final PathSegments path = params.getPath(); Device d = dips.findDeviceByFirstSegment(path); if (d != null) { return params.resolve(d, path.consume()); } d = dips.findDeviceByLastSegment(path); if (d != null) { return params.resolve(d, path.consumeLast()); } d = dips.findDeviceByLastSegmentExtension(path); if (d != null) { return params.resolve(d, path.removeExtension()); } return null; }