Converts the services IDs returned for usage in MN.
@param listServicesResult service result returned from AWS
@return RXJava publisher of the service list
338022
private Publisher<List<String>> convertServiceIds(ListServicesResult listServicesResult) {
        List<ServiceSummary> services = listServicesResult.getServices();
        List<String> serviceIds = new ArrayList<>();

        for (ServiceSummary service : services) {
            serviceIds.add(service.getId());
        }
        return Publishers.just(
                serviceIds
        );

    }
343695
public Observable<Page<ProviderInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<ProviderInner>>, Page<ProviderInner>>() {
                @Override
                public Page<ProviderInner> call(ServiceResponse<Page<ProviderInner>> response) {
                    return response.body();
                }
            });
    }
1132041
public static <T> List<T> buildSQLResult(SQLRestResponse result,Class<T> type){
		if(result == null || result.getRows() == null || result.getRows().size() == 0)
			return null;
		if(result.getRows() != null && result.getRows().size() > 0) {
			List<Object[]> rows = result.getRows();
			List<T> datas = new ArrayList<T>(rows.size());
			ColumnMeta[] metas = result.getColumns();
			if (Map.class.isAssignableFrom(type)) {
				Map<String,Object> data = null;
				for(int i = 0; i < rows.size(); i ++) {
					Object[] row = rows.get(i);
					data = new HashMap<String,Object>(metas.length);
					for (int j = 0; j < metas.length; j++) {
						data.put(metas[j].getName(),row[j]);
					}
					datas.add((T)data);
				}

			} else {
				DateFormat defaultDateFormat = SerialUtil.getDateFormateMeta().toDateFormat();
				T valueObject = null;
				for(int i = 0; i < rows.size(); i ++) {
					Object[] row = rows.get(i);
					valueObject = buildObject(type,  metas,  row,defaultDateFormat);
					datas.add(valueObject);
				}
			}
			return datas;
		}
		else {
			return null;
		}

	}
805600
@SuppressWarnings("unchecked")
  public <T> T api(Class<T> serviceInterface) {

    final ServiceCall serviceCall = this;
    final Map<Method, MethodInfo> genericReturnTypes = Reflect.methodsInfo(serviceInterface);

    // noinspection unchecked
    return (T)
        Proxy.newProxyInstance(
            getClass().getClassLoader(),
            new Class[] {serviceInterface},
            (proxy, method, params) -> {
              final MethodInfo methodInfo = genericReturnTypes.get(method);
              final Class<?> returnType = methodInfo.parameterizedReturnType();
              final boolean isServiceMessage = methodInfo.isRequestTypeServiceMessage();

              Optional<Object> check =
                  toStringOrEqualsOrHashCode(method.getName(), serviceInterface, params);
              if (check.isPresent()) {
                return check.get(); // toString, hashCode was invoked.
              }

              switch (methodInfo.communicationMode()) {
                case FIRE_AND_FORGET:
                  return serviceCall.oneWay(toServiceMessage(methodInfo, params));

                case REQUEST_RESPONSE:
                  return serviceCall
                      .requestOne(toServiceMessage(methodInfo, params), returnType)
                      .transform(asMono(isServiceMessage));

                case REQUEST_STREAM:
                  return serviceCall
                      .requestMany(toServiceMessage(methodInfo, params), returnType)
                      .transform(asFlux(isServiceMessage));

                case REQUEST_CHANNEL:
                  // this is REQUEST_CHANNEL so it means params[0] must be a publisher - its safe to
                  // cast.
                  return serviceCall
                      .requestBidirectional(
                          Flux.from((Publisher) params[0])
                              .map(data -> toServiceMessage(methodInfo, data)),
                          returnType)
                      .transform(asFlux(isServiceMessage));

                default:
                  throw new IllegalArgumentException(
                      "Communication mode is not supported: " + method);
              }
            });
  }
769918
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        try {
            if (com.google.api.ads.admanager.axis.v201902.OrderServiceInterface.class.isAssignableFrom(serviceEndpointInterface)) {
                com.google.api.ads.admanager.axis.v201902.OrderServiceSoapBindingStub _stub = new com.google.api.ads.admanager.axis.v201902.OrderServiceSoapBindingStub(new java.net.URL(OrderServiceInterfacePort_address), this);
                _stub.setPortName(getOrderServiceInterfacePortWSDDServiceName());
                return _stub;
            }
        }
        catch (java.lang.Throwable t) {
            throw new javax.xml.rpc.ServiceException(t);
        }
        throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface:  " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
    }
997150
public <T> void publisher(Class<T> api,
                          Result<T> result)
  {
    String path = api.getName();
      
    String address = address(path);
      
    ServicesAmp manager = ServicesAmp.current();
    ServiceRefAmp pubRef = manager.service(address);
      
    result.ok(pubRef.as(api));
  }
14542
public Observable<ServiceResponse<List<String>>> listDomainsWithServiceResponseAsync() {
        if (this.client.endpoint() == null) {
            throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
        }
        String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint());
        return service.listDomains(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<String>>>>() {
                @Override
                public Observable<ServiceResponse<List<String>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<List<String>> clientResponse = listDomainsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
579149
public GeocodingResult toGeocodingResult(
            final GeoServiceGeocodingResult gsResult) {
        if (gsResult == null) {
            return null;
        }
        final GeocodingResult result = new GeocodingResult();
        final AddressComponent[] addressComponents =
                gsResult.getAddressComponents();
        if (addressComponents == null) {
            result.addressComponents = null;
        } else {
            result.addressComponents =
                    new AddressComponent[addressComponents.length];
            for (int i = 0; i < addressComponents.length; i++) {
                result.addressComponents[i] = copy(addressComponents[i]);
            }
        }
        result.formattedAddress = gsResult.getFormattedAddress();
        result.geometry = toGeometry(gsResult.getGeometry());
        result.partialMatch = gsResult.isPartialMatch();
        result.placeId = gsResult.getPlaceId();
        // This is safe because the gs object returns a copy of its array.
        result.postcodeLocalities = gsResult.getPostcodeLocalities();
        // This is safe because the gs object returns a copy of its array.
        result.types = gsResult.getTypes();
        return result;
    }
1180058
@Override
  public AddressBookParsedResult parse(Result result) {
    String rawText = getMassagedText(result);
    if (!rawText.startsWith("BIZCARD:")) {
      return null;
    }
    String firstName = matchSingleDoCoMoPrefixedField("N:", rawText, true);
    String lastName = matchSingleDoCoMoPrefixedField("X:", rawText, true);
    String fullName = buildName(firstName, lastName);
    String title = matchSingleDoCoMoPrefixedField("T:", rawText, true);
    String org = matchSingleDoCoMoPrefixedField("C:", rawText, true);
    String[] addresses = matchDoCoMoPrefixedField("A:", rawText, true);
    String phoneNumber1 = matchSingleDoCoMoPrefixedField("B:", rawText, true);
    String phoneNumber2 = matchSingleDoCoMoPrefixedField("M:", rawText, true);
    String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true);
    String email = matchSingleDoCoMoPrefixedField("E:", rawText, true);

    return new AddressBookParsedResult(maybeWrap(fullName),
                                       null,
                                       null,
                                       buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3),
                                       null,
                                       maybeWrap(email),
                                       null,
                                       null,
                                       null,
                                       addresses,
                                       null,
                                       org,
                                       null,
                                       title,
                                       null,
                                       null);
  }
578365
public static List<Service> getServices(List<ServiceId> ids) {
        ProviderList list = Providers.getProviderList();
        return list.getServices(ids);
    }
270099
public static <T> IQueryResult<T> packageResult(List<T> results, CompletionStatus status) {
        return packageResult(results, status, null);
    }
1085513
@Override
    public Publisher<List<ServiceInstance>> getInstances(String serviceId) {
        if (serviceId == null) {
            serviceId = getRoute53ClientDiscoveryConfiguration().getAwsServiceId();  // we can default to the config file
        }
        ListInstancesRequest instancesRequest = new ListInstancesRequest().withServiceId(serviceId);
        Future<ListInstancesResult> instanceResult = getDiscoveryClient().listInstancesAsync(instancesRequest);
        Flowable<ListInstancesResult> observableInstanceResult = Flowable.fromFuture(instanceResult);
        return observableInstanceResult.flatMap(this::convertInstancesResulttoServiceInstances);
    }
885216
public static <T> IQueryResult<T> packageResult(List<T> results, CompletionStatus status, Map<String, Object> metadata) {
        return new QueryResult<T>(results, status, metadata);
    }
651027
public Observable<ServiceResponse<ImageIds>> getAllImageIdsWithServiceResponseAsync(String listId) {
        if (this.client.baseUrl() == null) {
            throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
        }
        if (listId == null) {
            throw new IllegalArgumentException("Parameter listId is required and cannot be null.");
        }
        String parameterizedHost = Joiner.on(", ").join("{baseUrl}", this.client.baseUrl());
        return service.getAllImageIds(listId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ImageIds>>>() {
                @Override
                public Observable<ServiceResponse<ImageIds>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ImageIds> clientResponse = getAllImageIdsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
1350445
@Override
    public Set<URI> listServicesWithOutputType(URI modelReference) {
        return this.listEntitiesByDataModel(MSM.Service, MSM.hasOutput, modelReference);
    }
1140570
protected SB toJavaSuper( SB sb ) {
    sb.nl();
    sb.ii(1);
    sb.i().p("public String[]   getNames() { return NAMES; } ").nl();
    sb.i().p("public String[][] getDomainValues() { return DOMAINS; }").nl();
    String uuid = this.uniqueId != null ? this.uniqueId.getId() : this._key.toString();
    sb.i().p("public String     getUUID() { return ").ps(uuid).p("; }").nl();

    return sb;
  }
147805
@Override
    public <KEY> boolean publish(Collection<MethodDescriptor<KEY>> descs) {
        if (CollectionUtil.isEmpty(descs)) {
            LOG.warn("No service to publish");
            return false;
        }

        List<String> methodNames = CollectionUtil.transform(descs,
                new Function<MethodDescriptor<KEY>, String>() {
                    @Override
                    public String apply(MethodDescriptor<KEY> input) {
                        return String.format("%s.%s(..)", input.getInterfClass().getSimpleName(),
                                input.getMethod().getName());
                    }
                });

        List<String> serviceNames = CollectionUtil.transform(descs,
                new Function<MethodDescriptor<KEY>, String>() {

                    @Override
                    public String apply(MethodDescriptor<KEY> input) {
                        return input.getInterfClass().getSimpleName();
                    }

                });

        Set<String> distinctServices = new HashSet<String>(serviceNames);

        Collections.sort(methodNames);
        Collections.sort(serviceNames);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Export rpc service methods which may include unneccessary methods: "
                    + Arrays.toString(methodNames.toArray(new String[] {})));
            LOG.debug("Export total " + methodNames.size() + " rpc service methods");
        }
        LOG.info("Export rpc services: "
                + Arrays.toString(distinctServices.toArray(new String[] {})));
        LOG.info("Export total " + distinctServices.size() + " rpc services");

        if (!RpcServerConf.ENABLE_ZK_REGISTRY) {
            LOG.info("Export services soley at localhost NOT register at zookeeper");
            return false;
        }

        if (!doConnectAndCreateZkPath()) {
            LOG.info("Export services failed at zookeeper and exit publishing");
            return false;
        }

        String localIp = ZkRegisterInfoUtil.getLocalHostIp();
        String localHostname = ZkRegisterInfoUtil.getLocalHostName();

        // override configuration files' port
        RpcServerConf.SERVER_PORT = Integer.valueOf(ZkRegisterInfoUtil.getLocalHostPort());

        List<String> failedRegistryServiceList = CollectionUtil.createArrayList();
        for (String service : distinctServices) {
            String zkPath = ZkPathUtil.buildPath(NaviCommonConstant.ZOOKEEPER_BASE_PATH,
                    RpcServerConf.ZK_REGISTRY_NAMESPACE, service, localIp + ":"
                            + RpcServerConf.SERVER_PORT);
            try {
                if (zkClient.exists(zkPath) != null) {
                    zkClient.delete(zkPath);
                }
                zkClient.createSessionNodeForRecursive(zkPath, localHostname.getBytes());
                LOG.info("Service registers at Zookeeper successfully - " + zkPath);
            } catch (NoNodeException e) {
                LOG.warn("Zookeeper path cannot found - " + zkPath);
            } catch (NodeExistsException e) {
                LOG.warn("Zookeeper path is already exists - " + zkPath);
            } catch (Exception e) {
                LOG.error("Zookeeper create path failed for " + zkPath, e);
                failedRegistryServiceList.add(zkPath);
            }
        }

        if (CollectionUtil.isEmpty(failedRegistryServiceList)) {
            LOG.info("Registry all " + (distinctServices.size() - failedRegistryServiceList.size())
                    + " services to zookeeper successfully");
        } else {
            LOG.info("Registry services to zookeeper encounter some problems, the failure registry paths are "
                    + Arrays.toString(failedRegistryServiceList.toArray(new String[] {})));
        }

        LOG.info("Publish for the " + republishCount.incrementAndGet() + " times");
        return true;
    }