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

com.anrisoftware.prefdialog.spreadsheetimportdialog.importpanel.VerticalPreferencesPanelFieldProvider Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2015 Erwin Müller 
 *
 * This file is part of prefdialog-spreadsheetimportdialog.
 *
 * prefdialog-spreadsheetimportdialog 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.
 *
 * prefdialog-spreadsheetimportdialog 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 Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with prefdialog-spreadsheetimportdialog. If not, see .
 */
package com.anrisoftware.prefdialog.spreadsheetimportdialog.importpanel;

import static java.util.ServiceLoader.load;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;

import com.anrisoftware.prefdialog.fields.FieldService;

/**
 * Provides the vertical preferences panel field service.
 * 
 * @author Erwin Mueller, [email protected]
 * @since 3.0
 */
@Singleton
class VerticalPreferencesPanelFieldProvider implements Provider {

	private static final String VERTICAL_PREFERENCES_PANEL_NAME = "VerticalPreferencesPanel";

	@Inject
	private VerticalPreferencesPanelFieldProviderLogger log;

	private final FieldService service;

	VerticalPreferencesPanelFieldProvider() {
		this.service = findService();
	}

	@Override
	public FieldService get() {
		return service;
	}

	private FieldService findService() {
		for (FieldService service : load(FieldService.class)) {
			if (service.getInfo().getAnnotationType().getSimpleName()
					.equals(VERTICAL_PREFERENCES_PANEL_NAME)) {
				return service;
			}
		}
		throw log.noService(this, VERTICAL_PREFERENCES_PANEL_NAME);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy