View Javadoc
1   package generated.model.de.fhdw.partner;
2   
3   import de.fhdw.wtf.context.model.AnyType;
4   import de.fhdw.wtf.context.model.collections.MutableList;
5   import de.fhdw.wtf.context.model.collections.MutableMap;
6   import de.fhdw.wtf.persistence.meta.UserObject;
7   
8   /**
9    * Represents the global phone number dictionary.
10   */
11  public class GlobalTelefonbuch extends AnyType {
12  	
13  	/**
14  	 * Maps pairs (city, phone number) to persons.
15  	 */
16  	private MutableMap<City, MutableList<MutableMap<Telefon, NatuerlichePerson>>> telefonbuchMapsPerCity;
17  	
18  	/**
19  	 * Returns the whole map from (city, phone number) pairs to persons.
20  	 * 
21  	 * @return A map from (city, phone number) pairs to persons.
22  	 */
23  	public MutableMap<City, MutableList<MutableMap<Telefon, NatuerlichePerson>>> getTelefonbuchMapsPerCity() {
24  		return this.telefonbuchMapsPerCity;
25  	}
26  	
27  	/**
28  	 * Adds a phone number dictionary of some city to this phone number dictionary.
29  	 * 
30  	 * @param city
31  	 *            The city.
32  	 * @param telefonbuch
33  	 *            The city's phone number dictionary.
34  	 */
35  	public void addTelefonbuchToCity(final City city, final Telefonbuch telefonbuch) {
36  		MutableList<MutableMap<Telefon, NatuerlichePerson>> set = this.telefonbuchMapsPerCity.get(city);
37  		if (set == null) {
38  			set = new MutableList<>();
39  			set.insert(telefonbuch.getEintraege());
40  			this.telefonbuchMapsPerCity.put(city, set);
41  		} else {
42  			set.insert(telefonbuch.getEintraege());
43  		}
44  	}
45  	
46  	/**
47  	 * Creates an empty GlobalTelefonbuch.
48  	 */
49  	public GlobalTelefonbuch() {
50  		this.telefonbuchMapsPerCity = new MutableMap<>();
51  	}
52  	
53  	/**
54  	 * Loads object from database.
55  	 * 
56  	 * @param userObject
57  	 *            The underlying user object.
58  	 */
59  	public GlobalTelefonbuch(final UserObject userObject) {
60  		super(userObject);
61  	}
62  }