Skip to content

Package: AbstractGeneratorFactory

AbstractGeneratorFactory

nameinstructionbranchcomplexitylinemethod
AbstractGeneratorFactory(String)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
create(Map)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Red Hat Inc and others.
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Red Hat Inc - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.kura.simulator.generator.basic;
14:
15: import org.eclipse.kapua.kura.simulator.generator.Generator;
16: import org.eclipse.kapua.kura.simulator.generator.GeneratorFactory;
17: import org.eclipse.kapua.kura.simulator.util.Get;
18:
19: import java.util.Map;
20: import java.util.Optional;
21:
22: public abstract class AbstractGeneratorFactory implements GeneratorFactory {
23:
24: private final Optional<String> type;
25:
26: protected AbstractGeneratorFactory(final String typeName) {
27: this.type = Optional.of(typeName);
28: }
29:
30: @Override
31: public Optional<Generator> create(final Map<String, Object> configuration) {
32: final Optional<String> type = Get.getNonEmptyString(configuration, "type");
33:• if (!this.type.equals(type)) {
34: return Optional.empty();
35: }
36:
37: return createFrom(configuration);
38: }
39:
40: protected abstract Optional<Generator> createFrom(Map<String, Object> configuration);
41: }