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

se.bjurr.violations.comments.lib.ChangedFileUtils Maven / Gradle / Ivy

The newest version!
package se.bjurr.violations.comments.lib;

import static java.util.Optional.empty;
import static java.util.Optional.ofNullable;

import java.util.List;
import java.util.Optional;
import se.bjurr.violations.comments.lib.model.ChangedFile;
import se.bjurr.violations.lib.model.Violation;

public class ChangedFileUtils {

  /**
   * When creating comment, the call should use the file as it is specified by the comments
   * provider. Not the one specified by the {@link Violation}. The one in the {@link Violation} may
   * not be recognized. 
*
* Here we make a guess on which file in the {@link CommentsProvider} to use. */ static Optional findChangedFile( final List files, final Violation violation) { for (final ChangedFile providerFile : files) { String violationFile = violation.getFile(); String fileFile = providerFile.getFilename(); if (violationFile.endsWith(fileFile) || fileFile.endsWith(violationFile)) { return ofNullable(providerFile); } } return empty(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy