/** * Removes the extension from the last segment. * @return The modified segments. */ public PathSegments removeExtension() { if (isEmpty()) { return this; } final String last = last(); final String removed = removeExtension(last); if (last.equals(removed)) { return this; } return new PathSegments(ImmutableList.copyOf(Iterables.concat(segments.subList(0, segments.size() - 1), ImmutableList.of(removed)))); }
/** * @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; }