![JAR search and dependency download from the Maven repository](/logo.png)
es.uam.eps.ir.relison.diffusion.sight.IndividualSightMechanism Maven / Gradle / Ivy
package es.uam.eps.ir.relison.diffusion.sight;
import es.uam.eps.ir.relison.diffusion.data.Data;
import es.uam.eps.ir.relison.diffusion.data.PropagatedInformation;
import es.uam.eps.ir.relison.diffusion.simulation.UserState;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Abstract implementation of a sight mechanism who values whether an information piece is observed by a user or not
* independently.
* @param type of the users.
* @param type of the information pieces.
* @param type of the parameters.
*/
public abstract class IndividualSightMechanism implements SightMechanism
{
@Override
public void resetSelections(Data data)
{
}
@Override
public List seesInformation(UserState user, Data data, List prop)
{
return prop.stream().filter(info -> this.seesInformation(user, data, info)).collect(Collectors.toCollection(ArrayList::new));
}
/**
* Checks if a user sees or not a piece of information.
* @param user the user.
* @param data the full data.
* @param prop the information piece received by a user.
* @return true if the user sees the piece, false if it does not.
*/
protected abstract boolean seesInformation(UserState user, Data data, PropagatedInformation prop);
}