Dirty Flag pattern #560

This commit is contained in:
Sia Wai Suan
2018-02-19 16:08:45 +00:00
parent e7b119c95c
commit b73ef6e6c5
8 changed files with 340 additions and 1 deletions

View File

@ -0,0 +1,47 @@
package com.iluwatar.dirtyflag;
import java.util.ArrayList;
import java.util.List;
/**
*
* A middle-layer app that calls/passes along data from the back-end.
*
* @author swaisuan
*
*/
public class World {
private static World world;
private static List<String> countries = new ArrayList<String>();
private World() {
}
/**
* Init.
*
* @return World instance
*/
public static World getInstance() {
if (world == null) {
world = new World();
}
return world;
}
/**
*
* Calls {@link DataFetcher} to fetch data from back-end.
*
* @return List of strings
*/
public List<String> fetch() {
DataFetcher df = DataFetcher.getInstance();
List<String> data = df.fetch();
countries = data == null ? countries : data;
return countries;
}
}