/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core;

import de.srsoftware.umbrella.core.api.*;

public class ModuleRegistry {
	private AccountingService accountingService;
	private BookmarkService bookmarkService;
	private CompanyService  companyService;
	private ContactService  contactService;
	private DocumentService documentService;
	private FileService     fileService;
	private MarkdownService markdownService;
	private NoteService     noteService;
	private PollService     pollService;
	private PostBox         postBox;
	private ProjectService  projectService;
	private StockService    stockService;
	private TagService      tagService;
	private TaskService     taskService;
	private TimeService     timeService;
	private Translator      translator;
	private UserService     userService;
	private WikiService     wikiService;

	private static final ModuleRegistry singleton = new ModuleRegistry();

	private ModuleRegistry(){}

	public static void add(Object service) {
		switch (service) {
			case AccountingService as: singleton.accountingService = as; break;
			case BookmarkService   bs: singleton.bookmarkService = bs; break;
			case CompanyService    cs: singleton.companyService  = cs; break;
			case ContactService    cs: singleton.contactService  = cs; break;
			case DocumentService   ds: singleton.documentService = ds; break;
			case FileService       fs: singleton.fileService     = fs; break;
			case StockService      is: singleton.stockService    = is; break;
			case MarkdownService   ms: singleton.markdownService = ms; break;
			case NoteService       ns: singleton.noteService     = ns; break;
			case PollService       ps: singleton.pollService     = ps; break;
			case PostBox           pb: singleton.postBox         = pb; break;
			case ProjectService    ps: singleton.projectService  = ps; break;
			case TagService        ts: singleton.tagService      = ts; break;
			case TaskService       ts: singleton.taskService     = ts; break;
			case TimeService       ts: singleton.timeService     = ts; break;
			case Translator        tr: singleton.translator      = tr; break;
			case UserService       us: singleton.userService     = us; break;
			case WikiService       ws: singleton.wikiService     = ws; break;
			case null: break;
			default: System.getLogger(ModuleRegistry.class.getSimpleName()).log(System.Logger.Level.WARNING,"Trying to add untracked class {0}",service.getClass().getSimpleName());
		}
	}

	public static AccountingService accountingService() {
		return singleton.accountingService;
	}

	public static BookmarkService bookmarkService(){
		return singleton.bookmarkService;
	}

	public static CompanyService companyService(){
		return singleton.companyService;
	}

	public static ContactService contactService() {
		return singleton.contactService;
	}

	public static DocumentService documentService(){
		return singleton.documentService;
	}

	public static StockService itemService(){
		return singleton.stockService;
	}

	public static FileService fileService(){
		return singleton.fileService;
	}

	public static MarkdownService markdownService(){
		return singleton.markdownService;
	}

	public static NoteService noteService(){
		return singleton.noteService;
	}

	public static PollService pollService() {
		return singleton.pollService;
	}

	public static PostBox postBox() {
		return singleton.postBox;
	}

	public static ProjectService projectService(){
		return singleton.projectService;
	}

	public static StockService stockService() { return singleton.stockService; }

	public static TagService tagService(){
		return singleton.tagService;
	}

	public static TaskService taskService(){
		return singleton.taskService;
	}

	public static TimeService timeService(){
		return singleton.timeService;
	}

	public static Translator translator(){
		return singleton.translator;
	}

	public static UserService userService(){
		return singleton.userService;
	}

	public static WikiService wikiService() { return singleton.wikiService; };
}
