// Path: src/main/java/ninja/eivind/hotsreplayuploader/models/ReplayFile.java
// @DatabaseTable(tableName = "ReplayFile")
// public class ReplayFile implements Serializable {
//     private static final Logger LOG = LoggerFactory.getLogger(ReplayFile.class);
//     private static final long serialVersionUID = 5416365418274150142L;
//     private final BooleanProperty failedProperty = new SimpleBooleanProperty(null, "failed", false);
//     @DatabaseField(generatedId = true)
//     private long id;
//     private File file;
//     @DatabaseField(width = 1023, unique = true)
//     private String fileName;
// 
//     @ForeignCollectionField(eager = true)
//     private Collection<UploadStatus> uploadStatuses = new ArrayList<>();
// 
//     public ReplayFile() {}
// 
//     public ReplayFile(final File file) {
//         this.file = file;
//         this.fileName = file.toString();
//     }
// 
//     public static List<ReplayFile> fromDirectory(File file) {
//         try {
//             return Files.walk(file.toPath(), FileVisitOption.FOLLOW_LINKS)
//                     .map(Path::toFile)
//                     .filter(f -> f.getName().endsWith(".StormReplay"))
//                     .map(ReplayFile::new)
//                     .collect(Collectors.toList());
//         } catch (IOException exception) {
//             LOG.debug("Ignored file {}. Cause : {}", file, exception);
//             return Collections.emptyList();
//         }
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     public void setId(final long id) {
//         this.id = id;
//     }
// 
//     public BooleanProperty getFailedProperty() {
//         return failedProperty;
//     }
// 
//     @Override
//     public String toString() {
//         return getFile().getName();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final ReplayFile that = (ReplayFile) o;
// 
//         return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return file != null ? file.hashCode() : 0;
//     }
// 
//     @JsonIgnore
//     public Status getStatus() {
//         // TODO MAKE MULTIPROVIDER-FRIENDLY
//         if (uploadStatuses.isEmpty()) {
//             return Status.NEW;
//         }
//         return uploadStatuses.iterator().next().getStatus();
//     }
// 
//     public File getFile() {
//         if (file == null && fileName != null) {
//             file = new File(fileName);
//         }
//         return file;
//     }
// 
//     public void addStatuses(final List<UploadStatus> list) {
//         uploadStatuses.addAll(list);
//     }
// 
//     public Collection<UploadStatus> getUploadStatuses() {
//         return uploadStatuses;
//     }
// 
//     public boolean hasExceptions() {
//         return uploadStatuses.stream()
//                 .anyMatch(uploadStatus -> uploadStatus.getStatus() == Status.EXCEPTION);
//     }
// 
//     public String getFileName() {
//         return fileName;
//     }
// 
//     public UploadStatus getUploadStatusForProvider(String provider) {
//         return getUploadStatuses().stream()
//                 .filter(status -> status.getHost().equals(provider))
//                 .findFirst()
//                 .orElse(null);
//     }
// }


import ninja.eivind.hotsreplayuploader.models.ReplayFile;
// Copyright 2015 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.files;


/**
 * Functional interface for listeners added to {@link AccountDirectoryWatcher}.
 */
@FunctionalInterface
public interface FileListener {

// Path: src/main/java/ninja/eivind/hotsreplayuploader/models/ReplayFile.java
// @DatabaseTable(tableName = "ReplayFile")
// public class ReplayFile implements Serializable {
//     private static final Logger LOG = LoggerFactory.getLogger(ReplayFile.class);
//     private static final long serialVersionUID = 5416365418274150142L;
//     private final BooleanProperty failedProperty = new SimpleBooleanProperty(null, "failed", false);
//     @DatabaseField(generatedId = true)
//     private long id;
//     private File file;
//     @DatabaseField(width = 1023, unique = true)
//     private String fileName;
// 
//     @ForeignCollectionField(eager = true)
//     private Collection<UploadStatus> uploadStatuses = new ArrayList<>();
// 
//     public ReplayFile() {}
// 
//     public ReplayFile(final File file) {
//         this.file = file;
//         this.fileName = file.toString();
//     }
// 
//     public static List<ReplayFile> fromDirectory(File file) {
//         try {
//             return Files.walk(file.toPath(), FileVisitOption.FOLLOW_LINKS)
//                     .map(Path::toFile)
//                     .filter(f -> f.getName().endsWith(".StormReplay"))
//                     .map(ReplayFile::new)
//                     .collect(Collectors.toList());
//         } catch (IOException exception) {
//             LOG.debug("Ignored file {}. Cause : {}", file, exception);
//             return Collections.emptyList();
//         }
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     public void setId(final long id) {
//         this.id = id;
//     }
// 
//     public BooleanProperty getFailedProperty() {
//         return failedProperty;
//     }
// 
//     @Override
//     public String toString() {
//         return getFile().getName();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final ReplayFile that = (ReplayFile) o;
// 
//         return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return file != null ? file.hashCode() : 0;
//     }
// 
//     @JsonIgnore
//     public Status getStatus() {
//         // TODO MAKE MULTIPROVIDER-FRIENDLY
//         if (uploadStatuses.isEmpty()) {
//             return Status.NEW;
//         }
//         return uploadStatuses.iterator().next().getStatus();
//     }
// 
//     public File getFile() {
//         if (file == null && fileName != null) {
//             file = new File(fileName);
//         }
//         return file;
//     }
// 
//     public void addStatuses(final List<UploadStatus> list) {
//         uploadStatuses.addAll(list);
//     }
// 
//     public Collection<UploadStatus> getUploadStatuses() {
//         return uploadStatuses;
//     }
// 
//     public boolean hasExceptions() {
//         return uploadStatuses.stream()
//                 .anyMatch(uploadStatus -> uploadStatus.getStatus() == Status.EXCEPTION);
//     }
// 
//     public String getFileName() {
//         return fileName;
//     }
// 
//     public UploadStatus getUploadStatusForProvider(String provider) {
//         return getUploadStatuses().stream()
//                 .filter(status -> status.getHost().equals(provider))
//                 .findFirst()
//                 .orElse(null);
//     }
// }


// Path: src/main/java/ninja/eivind/hotsreplayuploader/files/FileListener.java
import ninja.eivind.hotsreplayuploader.models.ReplayFile;

// Copyright 2015 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.files;


/**
 * Functional interface for listeners added to {@link AccountDirectoryWatcher}.
 */
@FunctionalInterface
public interface FileListener {

    void handle(ReplayFile file);