public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -0,0 +1,109 @@
package flintstones.entity.wvaluation;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import flintstones.entity.problemelement.ProblemElementKey;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.entity.valuation.Valuation;
/**
* The Class WValuation.
* Wrapper around Valuation to stick together a valuation and its ProblemElements
*/
public class WValuation {
/** The pek. */
ProblemElementKey pek;
/** The v. */
Valuation v;
/**
* Instantiates a new w valuation.
*
* @param pek the pek
* @param v the v
*/
public WValuation(ProblemElementKey pek, Valuation v) {
this.pek = pek;
this.v = v;
}
/**
* Instantiates a new w valuation.
*
* @param entry the entry
*/
public WValuation(Entry<ProblemElementKey,Valuation> entry) {
this(entry.getKey(), entry.getValue());
}
/**
* Instantiates a new w valuation.
*
* @param expert the expert
* @param alternative the alternative
* @param criterion the criterion
* @param valuation the valuation
*/
public WValuation(Expert expert, Alternative alternative, Criterion criterion, Valuation valuation) {
this(new ProblemElementKey(expert, alternative, criterion), valuation);
}
/**
* Gets the pek.
*
* @return the pek
*/
public ProblemElementKey getPEK() {
return pek;
}
/**
* Gets the valuation.
*
* @return the valuation
*/
public Valuation getValuation() {
return this.v;
}
/**
* Gets the valuations as array.
*
* @param waluations the waluations
* @return the valuations as array
*/
public static Valuation[] getValuationsAsArray(ArrayList<WValuation> waluations) {
return waluations.stream().map( k -> k.getValuation()).toArray(Valuation[]::new);
}
/**
* Gets the valuation as list.
*
* @param valuations the valuations
* @return the valuation as list
*/
public static ArrayList<Valuation> getValuationAsList(List<WValuation> valuations){
return (ArrayList<Valuation>) valuations.stream().map( k -> k.getValuation()).collect(Collectors.toList());
}
/**
* Gets the valuation as list.
*
* @param <T> the generic type
* @param valuations the valuations
* @param clazz the clazz
* @return the valuation as list
*/
public static <T> ArrayList<T> getValuationAsList(List<WValuation> valuations, Class<T> clazz){
return (ArrayList<T>) valuations.stream().map( k -> clazz.cast(k.getValuation()) ).collect(Collectors.toList());
}
}