org.nuiton.i18n.util.BeanPropertyI18nKeyProducerSupport Maven / Gradle / Ivy
The newest version!
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.Collections;
import java.util.Map;
/**
* Created by tchemit on 18/10/2018.
*
* @author Tony Chemit - [email protected]
*/
public abstract class BeanPropertyI18nKeyProducerSupport implements BeanPropertyI18nKeyProducer {
private final String i18nPrefix;
private final Map mapping;
protected BeanPropertyI18nKeyProducerSupport(String i18nPrefix) {
this.i18nPrefix = i18nPrefix;
this.mapping = createMapping();
}
protected Map createMapping() {
return Collections.emptyMap();
}
@Override
public String getI18nPropertyKey(Class type, String property) {
return i18nPrefix + mapping.getOrDefault(property, getI18nTypeKey(type) + ".") + property;
}
@Override
public String getI18nTypeKey(Class type) {
return type.getSimpleName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy