class RequestHandlerUtils extends AbstractRestHandler {

    protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir) {
        String serviceInstanceId = null;
        if (sir.getServiceInstanceId() != null) {
            serviceInstanceId = sir.getServiceInstanceId();
        } else {
            Optional<String> serviceInstanceIdForInstance = getServiceInstanceIdForInstanceGroup(requestScope, sir);
            if (serviceInstanceIdForInstance.isPresent()) {
                serviceInstanceId = serviceInstanceIdForInstance.get();
            }
        }
        return serviceInstanceId;
    }

}