/*
 * Copyright 2022 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.similarity;

import java.util.Objects;

import com.b2international.collections.PrimitiveLists;
import com.b2international.collections.floats.FloatList;
import com.b2international.index.Doc;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * @since 8.3
 */
@Doc(nested = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class Similarity {
	
	private final String source_value;
	private final FloatList predicted_value;

	@JsonCreator
	private Similarity(@JsonProperty("source_value") String sourceValue, @JsonProperty("predicted_value") FloatList predictedValue) {
		this.source_value = sourceValue;
		this.predicted_value = predictedValue;
	}
	
	public FloatList getPredicted_value() {
		return predicted_value;
	}
	
	public String getSource_value() {
		return source_value;
	}
	
	public static Similarity of(String sourceValue, float...predicatedValues) {
		return of(sourceValue, PrimitiveLists.newFloatArrayList(predicatedValues));
	}
	
	public static Similarity of(String sourceValue, FloatList predictedValue) {
		return new Similarity(sourceValue, predictedValue);
	}
	
	@Override
	public int hashCode() {
		return Objects.hash(source_value, predicted_value);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		Similarity other = (Similarity) obj;
		return Objects.equals(source_value, other.source_value) 
				&& Objects.equals(predicted_value, other.predicted_value);
	}
	
}


@@ -1053,19 +1053,20 @@
 ested = 
-tru
+fals
 e)%0A@Json
@@ -1162,26 +1162,25 @@
 tring source
-_v
+V
 alue;%0A%09priva
@@ -1203,26 +1203,25 @@
 st predicted
-_v
+V
 alue;%0A%0A%09@Jso
@@ -1369,26 +1369,25 @@
 %09this.source
-_v
+V
 alue = sourc
@@ -1406,26 +1406,25 @@
 is.predicted
-_v
+V
 alue = predi
@@ -1431,32 +1431,66 @@
 ctedValue;%0A%09%7D%0A%09%0A
+%09@JsonProperty(%22predicted_value%22)%0A
 %09public FloatLis
@@ -1499,26 +1499,25 @@
 getPredicted
-_v
+V
 alue() %7B%0A%09%09r
@@ -1527,26 +1527,25 @@
 rn predicted
-_v
+V
 alue;%0A%09%7D%0A%09%0A%09
@@ -1535,32 +1535,63 @@
 ctedValue;%0A%09%7D%0A%09%0A
+%09@JsonProperty(%22source_value%22)%0A
 %09public String g
@@ -1594,26 +1594,25 @@
 ng getSource
-_v
+V
 alue() %7B%0A%09%09r
@@ -1619,26 +1619,25 @@
 eturn source
-_v
+V
 alue;%0A%09%7D%0A%09%0A%09
@@ -1694,25 +1694,24 @@
 oat...predic
-a
 tedValues) %7B
@@ -1775,17 +1775,16 @@
 t(predic
-a
 tedValue
@@ -1989,26 +1989,25 @@
 .hash(source
-_v
+V
 alue, predic
@@ -2001,34 +2001,33 @@
 Value, predicted
-_v
+V
 alue);%0A%09%7D%0A%09%0A%09@Ov
@@ -2250,26 +2250,25 @@
 quals(source
-_v
+V
 alue, other.
@@ -2269,26 +2269,25 @@
 other.source
-_v
+V
 alue) %0A%09%09%09%09&
@@ -2308,26 +2308,25 @@
 ls(predicted
-_v
+V
 alue, other.
@@ -2330,26 +2330,25 @@
 er.predicted
-_v
+V
 alue);%0A%09%7D%0A%09%0A

use camelCase fields in Similarity type