All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redis.spring.batch.common.ToSuggestionFunction Maven / Gradle / Ivy

The newest version!
package com.redis.spring.batch.common;

import java.util.function.Function;
import java.util.function.ToDoubleFunction;

import com.redis.lettucemod.search.Suggestion;

public class ToSuggestionFunction implements Function> {

    private final Function string;

    private final ToDoubleFunction score;

    private final Function payload;

    public ToSuggestionFunction(Function string, ToDoubleFunction score, Function payload) {
        this.string = string;
        this.score = score;
        this.payload = payload;
    }

    @Override
    public Suggestion apply(T source) {
        Suggestion suggestion = new Suggestion<>();
        suggestion.setString(string.apply(source));
        suggestion.setScore(score.applyAsDouble(source));
        suggestion.setPayload(payload.apply(source));
        return suggestion;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy