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

ai.timefold.solver.jackson.api.domain.solution.ConstraintWeightOverridesSerializer Maven / Gradle / Ivy

Go to download

Timefold solves planning problems. This lightweight, embeddable planning engine implements powerful and scalable algorithms to optimize business resource scheduling and planning. This module contains the Jackson integration.

The newest version!
package ai.timefold.solver.jackson.api.domain.solution;

import java.io.IOException;

import ai.timefold.solver.core.api.domain.solution.ConstraintWeightOverrides;
import ai.timefold.solver.core.api.score.Score;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public final class ConstraintWeightOverridesSerializer>
        extends JsonSerializer> {

    @Override
    public void serialize(ConstraintWeightOverrides constraintWeightOverrides, JsonGenerator generator,
            SerializerProvider serializerProvider) throws IOException {
        generator.writeStartObject();
        for (var constraintName : constraintWeightOverrides.getKnownConstraintNames()) {
            var weight = constraintWeightOverrides.getConstraintWeight(constraintName);
            generator.writeStringField(constraintName, weight.toString());
        }
        generator.writeEndObject();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy