ch.sahits.game.openpatrician.model.city
Class CityFactory

java.lang.Object
  extended by ch.sahits.game.openpatrician.model.city.CityFactory

public class CityFactory
extends Object

Factory class for the cities of the game.

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 16, 2011

Field Summary
private static ConcurrentHashMap<String,ICity> createdCityCache
          Cache storing the already created cities to avoid duplicate creation
 
Constructor Summary
CityFactory()
           
 
Method Summary
static ICity createCityByName(ECityName cityName)
          Create a standard city based on its unique identification
static ICity createCityByName(String cityName)
          Create a standard city based on its name
private static ICity createIfNotStroed(ECityName name)
          Retrieve the city from the cache or create the city and put it there.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

createdCityCache

private static ConcurrentHashMap<String,ICity> createdCityCache
Cache storing the already created cities to avoid duplicate creation

Constructor Detail

CityFactory

public CityFactory()
Method Detail

createCityByName

public static ICity createCityByName(String cityName)
                              throws IOException
Create a standard city based on its name

Parameters:
cityName -
Returns:
Instance of the city
Throws:
IOException - Error reading the city properties

createCityByName

public static ICity createCityByName(ECityName cityName)
                              throws IOException
Create a standard city based on its unique identification

Parameters:
cityName -
Returns:
Instance of the city
Throws:
IOException - Error reading the city properties

createIfNotStroed

private static ICity createIfNotStroed(ECityName name)
                                throws IOException
Retrieve the city from the cache or create the city and put it there.

Parameters:
name - city name should not be null.
Returns:
city instance of null if the name is null
Throws:
IOException - Error reading the city properties


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.