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

org.eclipse.packager.rpm.build.ProviderRule Maven / Gradle / Ivy

There is a newer version: 0.21.0
Show newest version
/**
 * Copyright (c) 2015, 2019 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */

package org.eclipse.packager.rpm.build;

import java.io.IOException;
import java.util.Objects;

public class ProviderRule
{
    private final Class clazz;

    private final FileInformationProvider provider;

    public ProviderRule ( final Class clazz, final FileInformationProvider provider )
    {
        this.clazz = clazz;
        this.provider = provider;
    }

    public FileInformation run ( final String targetName, final Object object, final PayloadEntryType type ) throws IOException
    {
        Objects.requireNonNull ( object );

        if ( this.clazz.isAssignableFrom ( object.getClass () ) )
        {
            return this.provider.provide ( targetName, this.clazz.cast ( object ), type );
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy