All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ksyun.api.sdk.regions.Endpoint Maven / Gradle / Ivy

There is a newer version: 2.1.8
Show newest version
package com.ksyun.api.sdk.regions;

import java.util.List;
import java.util.Set;

import com.ksc.util.CollectionUtils;


public class Endpoint {
	private String name = null;
	private Set regionIds = null;
	private List productDomains = null;
	
	public Endpoint(String name, Set regionIds, List productDomains) {
		this.name = name;
		this.regionIds= regionIds;
		this.productDomains = productDomains;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Set getRegionIds() {
		return regionIds;
	}
	public void setRegionIds(Set regionIds) {
		this.regionIds = regionIds;
	}
	public List getProductDomains() {
		return productDomains;
	}
	public void setProductDomains(List productDomains) {
		this.productDomains = productDomains;
	}
	
	public static ProductDomain findProductDomain(String regionId, String product, List endpoints) {
		if (null == regionId || null == product || null == endpoints){
			return null;
		}
		for (Endpoint endpoint : endpoints) {
			if (endpoint.getRegionIds().contains(regionId)) {
				ProductDomain domain = findProductDomainByProduct(endpoint.getProductDomains(), product);
				return domain;
			} 
		}
		return null;
	}
	
	public static ProductDomain findProductDomain(List endpoints){
	    if(CollectionUtils.isNullOrEmpty(endpoints) || endpoints.get(0).getProductDomains().get(0) == null) 
	        return null;
	    return endpoints.get(0).getProductDomains().get(0);
	}
	
	private static ProductDomain findProductDomainByProduct(List productDomains, String product) {
		if(null == productDomains){
			return null;
		}
		for (ProductDomain productDomain : productDomains) {
			if(product.equalsIgnoreCase(productDomain.getProductName())){
				return productDomain;	
			}
		}
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy