ComponentContext<?> component = network.component(curi.getComponent());
if (component == null) {
throw new IllegalArgumentException("The URI component " + curi.getComponent() + " does not exist in the given network configuration");
}
if (curi.hasInstance()) {
InstanceContext instance = component.instance(curi.getInstance());
if (instance == null) {
throw new IllegalArgumentException("The URI instance " + curi.getInstance() + " does not exist in the given component configuration");
}
if (curi.hasEndpoint()) {
switch (curi.getEndpoint()) {
case ContextUri.ENDPOINT_IN:
InputContext input = instance.input();
if (curi.hasPort()) {
InputPortContext inPort = input.port(curi.getPort());
if (inPort == null) {
throw new IllegalArgumentException("The URI port " + curi.getPort() + " does not exist in the given input configuration");
}
return (T) inPort;
}
return (T) input;
case ContextUri.ENDPOINT_OUT:
OutputContext output = instance.output();
if (curi.hasPort()) {
OutputPortContext outPort = output.port(curi.getPort());
if (outPort == null) {
throw new IllegalArgumentException("The URI port " + curi.getPort() + " does not exist in the given output configuration");
}