Example usage for org.springframework.boot ApplicationArguments getOptionValues

List of usage examples for org.springframework.boot ApplicationArguments getOptionValues

Introduction

In this page you can find the example usage for org.springframework.boot ApplicationArguments getOptionValues.

Prototype

List<String> getOptionValues(String name);

Source Link

Document

Return the collection of values associated with the arguments option having the given name.

Usage

From source file:com.crossover.trial.weather.util.AirportLoader.java

@Override
public void run(ApplicationArguments args) throws Exception {
    if (args.containsOption("airports") && !args.getOptionValues("airports").isEmpty()) {
        File dataFile = new File(args.getOptionValues("airports").get(0));
        if (dataFile.canRead() && dataFile.isFile() && dataFile.exists()) {
            log.info("Loading airports from [{}]", dataFile);

            try (Stream<String> lines = Files.lines(dataFile.toPath())) {
                lines.map(Row::new).filter(Row::expectedTotalColumns).filter(Row::expectedColumnsFilled)
                        .map(Row::parse).filter(airport -> airport != null).forEach(airportRepository::save);
            }// ww w.j a  va  2  s .  c  o m

        } else
            log.error("Specified airports data file is not readable [{}]", dataFile.toPath());

    }
}

From source file:de.loercher.localpress.commons.LocalPressProperties.java

@Autowired
public LocalPressProperties(SecurityHelper pHelper, ApplicationArguments args) {
    helper = pHelper;/*from  w  w  w.  ja  v a2  s  . c  om*/
    prop = new Properties();

    List<String> propertyFileOptions = args.getOptionValues("props");

    String propertyFile = PROP_FILE;
    String securePropertyFile = SECURE_FILE;
    if (!(propertyFileOptions == null) && !propertyFileOptions.isEmpty()) {
        propertyFile = propertyFileOptions.get(0) + "\\" + PROP_FILE_ENDING;
        securePropertyFile = propertyFileOptions.get(0) + "\\" + SECURE_FILE_ENDING;
    }

    propertyFile = propertyFile.replace("\\", "/");
    securePropertyFile = securePropertyFile.replace("\\", "/");

    initProperties(propertyFile, securePropertyFile);
}