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

com.at.avro.formatters.DecimalFormatter Maven / Gradle / Ivy

The newest version!
package com.at.avro.formatters;

import com.at.avro.config.FormatterConfig;
import com.at.avro.types.Decimal;

import static java.lang.String.format;

/**
 * @author [email protected]
 */
public class DecimalFormatter implements Formatter {

    @Override
    public String toJson(Decimal decimal, FormatterConfig config) {
        String template = "{ \"type\":\"%s\", \"java-class\":\"%s\", \"logicalType\":\"%s\", \"precision\":%s, \"scale\":%s }"
            .replaceAll(":", config.colon());

        return format(template,
                decimal.getPrimitiveType(),
                decimal.getJavaClass(),
                decimal.getLogicalType(),
                decimal.getPrecision(),
                decimal.getScale());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy