/*
 * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.snomed.datastore.request;

import java.util.Collection;

import com.b2international.snowowl.datastore.request.SearchRequest;
import com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers;
import com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequest.OptionKey;
import com.b2international.snowowl.snomed.snomedrefset.SnomedRefSetType;
import com.google.common.collect.ImmutableSet;

/**
 * @since 4.5
 */
public final class SnomedRefSetMemberSearchRequestBuilder extends SnomedSearchRequestBuilder<SnomedRefSetMemberSearchRequestBuilder, SnomedReferenceSetMembers> {

	SnomedRefSetMemberSearchRequestBuilder(String repositoryId) {
		super(repositoryId);
	}
	
	@Override
	protected SearchRequest<SnomedReferenceSetMembers> create() {
		return new SnomedRefSetMemberSearchRequest();
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSet(String referenceSetId) {
		return addOption(OptionKey.REFSET, referenceSetId);
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSet(Collection<String> referenceSetIds) {
		return addOption(OptionKey.REFSET, ImmutableSet.copyOf(referenceSetIds));
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByReferencedComponent(String referencedComponentId) {
		return addOption(OptionKey.REFERENCED_COMPONENT, referencedComponentId);
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByReferencedComponent(Collection<String> referencedComponentIds) {
		return addOption(OptionKey.REFERENCED_COMPONENT, ImmutableSet.copyOf(referencedComponentIds));
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSetType(final Iterable<SnomedRefSetType> refSetTypes) {
		return addOption(OptionKey.REFSET_TYPE, ImmutableSet.copyOf(refSetTypes));
	}
}

/*
 * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.snomed.datastore.request;

import java.util.Collection;

import com.b2international.snowowl.datastore.request.SearchRequest;
import com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers;
import com.b2international.snowowl.snomed.datastore.request.SnomedRefSetMemberSearchRequest.OptionKey;
import com.b2international.snowowl.snomed.snomedrefset.SnomedRefSetType;
import com.google.common.collect.ImmutableSet;

/**
 * @since 4.5
 */
public final class SnomedRefSetMemberSearchRequestBuilder extends SnomedSearchRequestBuilder<SnomedRefSetMemberSearchRequestBuilder, SnomedReferenceSetMembers> {

	SnomedRefSetMemberSearchRequestBuilder(String repositoryId) {
		super(repositoryId);
	}
	
	@Override
	protected SearchRequest<SnomedReferenceSetMembers> create() {
		return new SnomedRefSetMemberSearchRequest();
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSet(String referenceSetId) {
		return addOption(OptionKey.REFSET, referenceSetId);
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSet(Collection<String> referenceSetIds) {
		return addOption(OptionKey.REFSET, ImmutableSet.copyOf(referenceSetIds));
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByReferencedComponent(String referencedComponentId) {
		return addOption(OptionKey.REFERENCED_COMPONENT, referencedComponentId);
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByReferencedComponent(Collection<String> referencedComponentIds) {
		return addOption(OptionKey.REFERENCED_COMPONENT, ImmutableSet.copyOf(referencedComponentIds));
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSetType(final SnomedRefSetType...refSetTypes) {
		return addOption(OptionKey.REFSET_TYPE, ImmutableSet.copyOf(refSetTypes));
	}
	
	public SnomedRefSetMemberSearchRequestBuilder filterByRefSetType(final Iterable<SnomedRefSetType> refSetTypes) {
		return addOption(OptionKey.REFSET_TYPE, ImmutableSet.copyOf(refSetTypes));
	}
}

add vararg version of filterByRefSetType