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

com.github.zhengframework.configuration.io.CombinedLocationStrategy Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.github.zhengframework.configuration.io;

import com.google.common.base.Preconditions;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;

public class CombinedLocationStrategy implements FileLocationStrategy {

  private final Collection subStrategies;

  public CombinedLocationStrategy(
      Collection subStrategies) {
    Preconditions
        .checkState(subStrategies != null, "Collection with sub strategies must not be null!");
    this.subStrategies = Collections.unmodifiableCollection(subStrategies);
  }

  @Override
  public Optional locate(FileSystem fileSystem, FileLocator locator) {
    for (final FileLocationStrategy sub : subStrategies) {
      Optional optional = sub.locate(fileSystem, locator);
      if (optional.isPresent()) {
        return optional;
      }
    }
    return Optional.empty();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy