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

de.pfabulist.loracle.license.LicenseIDs Maven / Gradle / Ivy

Go to download

maven plugin to check the licenses of all dependencies and possible incompatibilities

There is a newer version: 2.0.1
Show newest version
package de.pfabulist.loracle.license;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Copyright (c) 2006 - 2016, Stephan Pfab
 * SPDX-License-Identifier: BSD-2-Clause
 */

public class LicenseIDs {

    public static boolean isOr( LicenseID license ) {
        return license instanceof CompositeLicense && ( (CompositeLicense) license ).isOr();
    }

    public static boolean isAnd( LicenseID license ) {
        return license instanceof CompositeLicense && ( (CompositeLicense) license ).isAnd();
    }

    public static List flattenToStrings( LicenseID license ) {
        if ( license instanceof CompositeLicense ) {
            CompositeLicense cl = (CompositeLicense)license;
            List ret = new ArrayList<>();
            ret.addAll( flattenToStrings( cl.getLeft() ) );
            ret.addAll( flattenToStrings( cl.getRight() ) );
            return ret;
        }

        if ( license instanceof SingleLicense ) {
            return Collections.singletonList( license.toString() );
        }

        if ( license instanceof ModifiedSingleLicense ) {
            ModifiedSingleLicense msl = (ModifiedSingleLicense)license;
            List ret = new ArrayList<>();
            ret.add( msl.getBase() );
            msl.getException().ifPresent( ex -> ret.add( ex.toString() ) );
            return ret;

        }

        return Collections.emptyList();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy