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

io.virtdata.formatting.Format Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
package io.virtdata.formatting;

import io.virtdata.annotations.Example;
import io.virtdata.annotations.ThreadSafeMapper;

import java.util.function.Function;

/**
 * Apply the Java String.format method to an incoming object.
 * @see Java 8 String.format(...) javadoc
 * Note: This function can often be quite slow, so more direct methods are generally preferrable.
 */
@ThreadSafeMapper
public class Format implements Function {

    private final String format;

    @Example({"Format('Y')","Yield the formatted year from a Java date object."})
    public Format(String format) {
        this.format = format;
    }

    @Override
    public String apply(Object o) {
        return String.format(format,o);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy