Extended EventBase to have multiple sailorsInfoWebsiteURLs that are

mapped by Locales
This commit is contained in:
Steffen Schaefer committed 2016-02-24 13:12:41 +01:00
1 parent de5dc5b517
commit e511b30f22
2 files changed
+31 -3

No files matched your search

@@ -1,6 +1,7 @@
package com.sap.sailing.domain.base;
import java.net.URL;
import java.util.Locale;
import java.util.Map;
import com.sap.sailing.domain.common.Renamable;
@@ -88,6 +89,10 @@ public interface EventBase extends Named, WithDescription, Renamable, WithID, Wi
URL getSailorsInfoWebsiteURL();
void setSailorsInfoWebsiteURL(URL sailorsInfoWebsiteURL);
Map<Locale, URL> getSailorsInfoWebsiteURLs();
void setSailorsInfoWebsiteURLs(Map<Locale, URL> sailorsInfoWebsiteURLs);
Iterable<? extends LeaderboardGroupBase> getLeaderboardGroups();
@@ -5,7 +5,9 @@ import java.io.ObjectInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -36,7 +38,7 @@ public abstract class EventBaseImpl implements EventBase {
private TimePoint startDate;
private TimePoint endDate;
private URL officialWebsiteURL;
private URL sailorsInfoWebsiteURL;
private Map<Locale, URL> sailorsInfoWebsiteURLs;
private ConcurrentLinkedQueue<ImageDescriptor> images;
private ConcurrentLinkedQueue<VideoDescriptor> videos;
@@ -57,6 +59,7 @@ public abstract class EventBaseImpl implements EventBase {
this.isPublic = isPublic;
this.images = new ConcurrentLinkedQueue<ImageDescriptor>();
this.videos = new ConcurrentLinkedQueue<VideoDescriptor>();
this.sailorsInfoWebsiteURLs = Collections.synchronizedMap(new HashMap<Locale, URL>());
}
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
@@ -67,6 +70,9 @@ public abstract class EventBaseImpl implements EventBase {
if (videos == null) {
videos = new ConcurrentLinkedQueue<VideoDescriptor>();
}
if (sailorsInfoWebsiteURLs == null) {
sailorsInfoWebsiteURLs = Collections.synchronizedMap(new HashMap<Locale, URL>());
}
}
@Override
@@ -185,12 +191,29 @@ public abstract class EventBaseImpl implements EventBase {
@Override
public URL getSailorsInfoWebsiteURL() {
return sailorsInfoWebsiteURL;
return sailorsInfoWebsiteURLs.get(null);
}
@Override
public void setSailorsInfoWebsiteURL(URL sailorsInfoWebsiteURL) {
this.sailorsInfoWebsiteURL = sailorsInfoWebsiteURL;
if(sailorsInfoWebsiteURL == null) {
this.sailorsInfoWebsiteURLs.remove(null);
} else {
this.sailorsInfoWebsiteURLs.put(null, sailorsInfoWebsiteURL);
}
}
@Override
public Map<Locale, URL> getSailorsInfoWebsiteURLs() {
return Collections.unmodifiableMap(sailorsInfoWebsiteURLs);
}
@Override
public void setSailorsInfoWebsiteURLs(Map<Locale, URL> sailorsInfoWebsiteURLs) {
this.sailorsInfoWebsiteURLs.clear();
if(sailorsInfoWebsiteURLs != null) {
this.sailorsInfoWebsiteURLs.putAll(sailorsInfoWebsiteURLs);
}
}
@Override