class ArtifactToComponentUtils {

    public static String createComponentName(Artifact artifact) {
        return artifact.askFor(ArtifactCoordinates.class)
                .map(ArtifactCoordinates::getMainCoordinate)
                .map(ArtifactToComponentUtils::createNameForCoordinate)
                .orElseGet(() -> artifact.askFor(ArtifactFilename.class)
                        .flatMap(ArtifactFilename::getBestFilenameEntryGuess)
                        .map(ArtifactFilenameEntry::getFilename)
                        .orElseThrow(
                                () -> new ExecutionException("Artifact " + artifact.prettyPrint() + " does not have " +
                                        "enough facts to create a component name. Please provide more information " +
                                        "by an analyzer (" + artifact.getAnalysisSource() + ")")));
    }

    private  ArtifactToComponentUtils();

}