package com.github.sarxos.xchange;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.sarxos.xchange.impl.FetchOpenExchangeImpl;
import com.github.sarxos.xchange.impl.FetchYahooImpl;


public class ExchangeQuery {

	/**
	 * I'm the logger.
	 */
	private static final Logger LOG = LoggerFactory.getLogger(ExchangeQuery.class);

	/**
	 * Convert from currency.
	 */
	private Collection<String> from;

	/**
	 * Convert to currency.
	 */
	private String to;

	public ExchangeQuery from(String... symbols) {
		from = new ArrayList<>(Arrays.asList(symbols));
		return this;
	}

	public ExchangeQuery from(Collection<String> symbols) {
		from = symbols;
		return this;
	}

	public ExchangeQuery to(String symbol) {
		to = symbol;
		return this;
	}

	public Collection<ExchangeRate> get() throws ExchangeException {

		// first, try Yahoo

		try {
			return new FetchYahooImpl().get(to, from);
		} catch (ExchangeException e) {
			LOG.error("Unable to get exchange data from Yahoo", e);
		}

		// then, if Yahoo failed, try OpenExchange

		try {
			return new FetchOpenExchangeImpl().get(to, from);
		} catch (ExchangeException e) {
			LOG.error("Unable to get exchange data from Yahoo", e);
		}

		return null;
	}

	public static void main(String[] args) throws ExchangeException {

		for (ExchangeRate r : new ExchangeQuery()
			.from("EUR", "JPY", "BGN", "PLN", "MXN", "ZAR", "LVL", "ZMK", "GBP")
			.to("GBP")
			.get()) {
			System.out.println(r);
		}
	}
}

@@ -110,16 +110,46 @@
 lection;
+%0Aimport java.util.Collections;
 %0A%0Aimport
@@ -941,16 +941,122 @@
 tion %7B%0A%0A
+%09%09// return empty list if input is empty%0A%0A%09%09if (from.isEmpty()) %7B%0A%09%09%09return Collections.emptyList();%0A%09%09%7D%0A%0A
 %09%09// fir

Return empty list in case when input is empty