private static Set<Origin> withAppId(Collection<Origin> origins, String appId) { return origins.stream().map(origin -> newOriginBuilder(origin) .applicationId(appId) .build()) .collect(toSet()); }
/** * Creates a new Origin builder. * * @param host hostname * @param port port * @return a new Origin builder */ public static Builder newOriginBuilder(String host, int port) { return new Builder(HostAndPort.fromParts(host, port)); }
/** * Creates a new Origin builder. * * @param host host and port * @return a new Origin builder */ public static Builder newOriginBuilder(HostAndPort host) { return new Builder(host); }
private static Origin originFromRequest(HttpRequest request) { String hostAndPort = request.header(HOST) .orElseGet(() -> { checkArgument(request.url().isAbsolute(), "host header is not set for request=%s", request); return request.url().authority().map(Url.Authority::hostAndPort) .orElseThrow(() -> new IllegalArgumentException("Cannot send request " + request + " as URL is not absolute and no HOST header is present")); }); return newOriginBuilder(HostAndPort.fromString(hostAndPort)).build(); }
/** * Creates a new builder from an existing origin that will inherit the properties of that origin. * * @param origin an existing origin * @return a new builder inheriting its properties */ public static Builder newOriginBuilder(Origin origin) { return new Builder(origin); }