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

org.eclipse.kapua.kura.simulator.generator.basic.AbstractGeneratorFactory Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2017 Red Hat Inc and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat Inc - initial API and implementation
 *******************************************************************************/
package org.eclipse.kapua.kura.simulator.generator.basic;

import org.eclipse.kapua.kura.simulator.generator.Generator;
import org.eclipse.kapua.kura.simulator.generator.GeneratorFactory;
import org.eclipse.kapua.kura.simulator.util.Get;

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

public abstract class AbstractGeneratorFactory implements GeneratorFactory {

    private final Optional type;

    protected AbstractGeneratorFactory(final String typeName) {
        this.type = Optional.of(typeName);
    }

    @Override
    public Optional create(final Map configuration) {
        final Optional type = Get.getNonEmptyString(configuration, "type");
        if (!this.type.equals(type)) {
            return Optional.empty();
        }

        return createFrom(configuration);
    }

    protected abstract Optional createFrom(Map configuration);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy