/** * Changes the base scheme, host and port of this MutableUri to that specified in a base URI, or * leaves them unchanged if the base URI is {@code null}. This implementation only uses scheme, * host and port. The remaining components of the URI remain intact. * * @param base the URI to base the other URI on. * @return this (rebased) instance */ public MutableUri rebase(MutableUri base) { if (base == null) { return this; } String scheme = base.getScheme(); String host = base.getHost(); int port = base.getPort(); if (scheme == null || host == null) { return this; } try { setScheme(scheme); setHost(host); setPort(port); } catch (URISyntaxException e) { throw new IllegalStateException(e); } return this; }