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

org.nuiton.i18n.util.BeanPropertyI18nKeyProducerProvider Maven / Gradle / Ivy

package org.nuiton.i18n.util;

/*-
 * #%L
 * I18n :: Api
 * %%
 * Copyright (C) 2004 - 2018 Code Lutin, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * Created by tchemit on 18/10/2018.
 *
 * @author Tony Chemit - [email protected]
 */
public abstract class BeanPropertyI18nKeyProducerProvider {

    private static BeanPropertyI18nKeyProducerProvider INSTANCE;

    public static BeanPropertyI18nKeyProducerProvider get() {
        if (INSTANCE == null) {
            Iterator iterator = ServiceLoader.load(BeanPropertyI18nKeyProducerProvider.class).iterator();
            if (!iterator.hasNext()) {
                throw new IllegalStateException("No BeanPropertyI18nKeyProducerProvider instance found.");
            }
            INSTANCE = iterator.next();
            if (iterator.hasNext()) {
                throw new IllegalStateException("More than one BeanPropertyI18nKeyProducerProvider instance found.");
            }
        }
        return INSTANCE;
    }

    protected abstract String getCommonPrefix();

    public abstract BeanPropertyI18nKeyProducer getDefaultLabelsBuilder();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy