ai.timefold.solver.jackson.api.domain.solution.ConstraintWeightOverridesSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timefold-solver-jackson Show documentation
Show all versions of timefold-solver-jackson Show documentation
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();
}
}