Package: ObserverFactory
ObserverFactory
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
createObserver() |
|
|
|
|
|
||||||||||||||||||||
getInputProvider(InputProvider) |
|
|
|
|
|
Coverage
1: /*
2: * Copyright © 2020-2023 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of gaming-core.
5: *
6: * Gaming-core is free software: you can redistribute it and/or modify it under
7: * the terms of the GNU General Public License as published by the Free Software
8: * Foundation, either version 3 of the License, or (at your option) any later
9: * version.
10: *
11: * Gaming-core is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * gaming-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.core.domain;
20:
21: import java.util.Map;
22:
23: import de.fhdw.gaming.core.ui.InputProvider;
24: import de.fhdw.gaming.core.ui.InputProviderException;
25: import de.fhdw.gaming.core.ui.util.NonInteractiveInputProvider;
26:
27: /**
28: * Allows to create an {@link Observer}.
29: */
30: public interface ObserverFactory {
31:
32: /**
33: * Returns the name of the {@link ObserverFactory}.
34: */
35: String getName();
36:
37: /**
38: * Creates an {@link Observer} object.
39: *
40: * @param parameters The parameters for the observer.
41: */
42: Observer createObserver(Map<String, Object> parameters);
43:
44: /**
45: * Creates an {@link Observer} object with default parameters.
46: */
47: default Observer createObserver() throws InputProviderException {
48: return this.createObserver(this.getInputProvider(
49: new NonInteractiveInputProvider()).requestData(this.getName()));
50: }
51:
52: /**
53: * Allows to customise an {@link InputProvider} for retrieving needed parameters.
54: *
55: * @param inputProvider The {@link InputProvider} to customise.
56: * @return The customised {@link InputProvider}.
57: */
58: default InputProvider getInputProvider(final InputProvider inputProvider) throws InputProviderException {
59: return inputProvider;
60: }
61: }