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

tech.ydb.yoj.DeprecationWarnings Maven / Gradle / Ivy

Go to download

Core data-binding logic used by YOJ (YDB ORM for Java) to convert between Java objects and database rows (or anything representable by a Java Map, really).

The newest version!
package tech.ydb.yoj;

import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public final class DeprecationWarnings {
    private static final Logger log = LoggerFactory.getLogger(DeprecationWarnings.class);
    private static final Set warnings = Collections.newSetFromMap(new ConcurrentHashMap<>());

    private DeprecationWarnings() {
    }

    public static void warnOnce(String key, String msg, Object... args) {
        if (warnings.add(key)) {
            var formattedMsg = Strings.lenientFormat(msg, args);
            log.warn(formattedMsg, new Throwable(key + " stack trace"));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy