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

com.kenshoo.pl.entity.spi.audit.DefaultAuditFieldValueFormatter Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
package com.kenshoo.pl.entity.spi.audit;

import com.kenshoo.pl.entity.EntityField;

import java.util.Optional;

import static java.util.Objects.requireNonNull;

/**
 * This is the default formatter for field values to be included in an AuditRecord.
* It formats values using the {@code String} {@link com.kenshoo.pl.entity.ValueConverter} defined for a given field.
* If no such converter is defined, the default string representation of the value is returned.
* * @see EntityField#getStringValueConverter() */ public class DefaultAuditFieldValueFormatter implements AuditFieldValueFormatter { public static final AuditFieldValueFormatter INSTANCE = new DefaultAuditFieldValueFormatter(); private DefaultAuditFieldValueFormatter() { // singleton } @Override public String format(final EntityField field, final T value) { requireNonNull(field, "A field is required"); requireNonNull(value, "A value is required"); return Optional.ofNullable(field.getStringValueConverter()) .map(converter -> converter.convertTo(value)) .orElse(String.valueOf(value)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy