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

templates.qeex.QeexConfig.ftl Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package ${groupId}.api.qeex.annotations;


import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithName;

import java.util.Map;
import java.util.Optional;
import java.util.Set;

@ConfigMapping(prefix = "qeex")
public interface QeexConfig {

    @WithName("project")
    Optional project();

    @WithName("default.id")
    Optional default_id();

    @WithName("default.code")
    Optional default_code();

    @WithName("default.language")
    Optional default_language();

    @WithName("default.message")
    Optional default_message();

    @WithName("messages")
    Set messages();

    interface Message {
        Optional message();

        Optional code();

        Optional id();

        Map language();
    }

    default Integer get_code(int id, Integer code) {
        if (code == null) {
            return default_code().get();
        }
        for (Message msg : messages()) {
            if (msg.id().isPresent() && msg.id().get().equals(id)) {
                if (msg.code().isPresent()) {
                    return msg.code().get();
                }
            }
        }
        return code;
    }

    default String get_message(int id, String message, String language) {
        var lang = default_language().get();
        if (language != null) {
            lang = language;
        }
        for (Message msg : messages()) {
            if (msg.id().isPresent() && msg.id().get().equals(id)) {
                if (lang != null && msg.language().containsKey(language)) {
                    return msg.language().get(language);
                }
                if (msg.message().isPresent()) {
                    return msg.message().get();
                }
            }
        }
        return message;
    }

    default String get_language(int id, String language) {
        if (language == null) {
            return default_language().get();
        }
        for (Message msg : messages()) {
            if (msg.id().isPresent() && msg.id().get().equals(id)) {
                if (msg.message().isPresent()) {
                    if (msg.language().containsKey(language)) {
                        return language;
                    }
                }
            }
        }
        return default_language().get();
    }

    default String get_project(String project) {
        return project().orElse(project);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy