/*
 * Copyright 2020 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.core.compare;

import java.util.Objects;
import java.util.function.BiFunction;

import com.b2international.snowowl.core.domain.ConceptMapMapping;

/**
 * @since 7.11
 */
public enum ConceptMapCompareConfigurationProperties {

	CODE_SYSTEM(
			"Code System", 
			(member1, member2) -> Objects.equals(member1.getSourceComponentURI().codeSystem(), member2.getSourceComponentURI().codeSystem()),
			(member1, member2) -> Objects.equals(member1.getTargetComponentURI().codeSystem(), member2.getTargetComponentURI().codeSystem())
			),

	TERM(
			"Term", 
			(member1, member2) -> Objects.equals(member1.getSourceTerm(), member2.getSourceTerm()),
			(member1, member2) -> Objects.equals(member1.getTargetTerm(), member2.getTargetTerm())
			),

	CODE(
			"Code", 
			(member1, member2) -> Objects.equals(member1.getSourceComponentURI().identifier(), member2.getSourceComponentURI().identifier()),
			(member1, member2) -> Objects.equals(member1.getTargetComponentURI().identifier(), member2.getTargetComponentURI().identifier())
			);

	private final String label;
	private final BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getSourceEqualFunction;
	private final BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getTargetEqualFunction;

	private ConceptMapCompareConfigurationProperties(final String label, 
			final BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getSourceEqualFunction, 
			final BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getTargetEqualFunction) {
		this.label = label;
		this.getSourceEqualFunction = getSourceEqualFunction;
		this.getTargetEqualFunction = getTargetEqualFunction;
	}

	public String getLabel() {
		return label;
	}

	public BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getSourceEqualFunction() {
		return getSourceEqualFunction;
	}

	public BiFunction<ConceptMapMapping, ConceptMapMapping, Boolean> getTargetEqualFunction() {
		return getTargetEqualFunction;
	}

	public Boolean isSourceEqual(ConceptMapMapping member1, ConceptMapMapping member2) {
		return getSourceEqualFunction.apply(member1, member2);
	}

	public Boolean isTargetEqual(ConceptMapMapping member1, ConceptMapMapping member2) {
		return getTargetEqualFunction.apply(member1, member2);
	}

	@Override
	public String toString() {
		return label;
	}
	
}

@@ -693,16 +693,38 @@
 bjects;%0A
+import java.util.Set;%0A
 import j
@@ -819,16 +819,63 @@
 Mapping;
+%0Aimport com.google.common.collect.ImmutableSet;
 %0A%0A/**%0A *
@@ -1750,16 +1750,484 @@
 %0A%09%09%09);%0A%0A
+%09public static final Set%3CConceptMapCompareConfigurationProperties%3E ALL_PROPERTIES = ImmutableSet.of(ConceptMapCompareConfigurationProperties.CODE_SYSTEM, ConceptMapCompareConfigurationProperties.CODE, ConceptMapCompareConfigurationProperties.TERM);%0A%09public static final Set%3CConceptMapCompareConfigurationProperties%3E DEFAULT_SELECTED_PROPERTIES = ImmutableSet.of(ConceptMapCompareConfigurationProperties.CODE_SYSTEM, ConceptMapCompareConfigurationProperties.CODE);%0A%09%09%09%0A
 %09private

create constants for easier usage