-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Agadar/dev-4.0.0
Dev 4.0.0
- Loading branch information
Showing
86 changed files
with
4,129 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/target/ | ||
/nbproject/ | ||
/nbproject/ | ||
.classpath | ||
.project | ||
.settings/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/main/java/com/github/agadar/nationstates/adapter/ColonSeparatedToListAdapter.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/github/agadar/nationstates/adapter/ColonSeparatedToSetAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.agadar.nationstates.adapter; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.xml.bind.annotation.adapters.XmlAdapter; | ||
|
||
/** | ||
* Converts a colon-separated String to a Set of Strings and vice versa. | ||
* | ||
* @author Agadar (https://github.com/Agadar/) | ||
*/ | ||
public final class ColonSeparatedToSetAdapter extends XmlAdapter<String, Set<String>> { | ||
|
||
@Override | ||
public String marshal(Set<String> bt) { | ||
return String.join(":", bt); | ||
} | ||
|
||
@Override | ||
public Set<String> unmarshal(String vt) { | ||
return new HashSet<>(Arrays.asList(vt.split(":"))); | ||
} | ||
|
||
} |
25 changes: 0 additions & 25 deletions
25
src/main/java/com/github/agadar/nationstates/adapter/CommaSeparatedToListAdapter.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/github/agadar/nationstates/adapter/CommaSeparatedToSetAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.agadar.nationstates.adapter; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.xml.bind.annotation.adapters.XmlAdapter; | ||
|
||
/** | ||
* Converts a comma-separated String to a Set of Strings and vice versa. | ||
* | ||
* @author Agadar (https://github.com/Agadar/) | ||
*/ | ||
public final class CommaSeparatedToSetAdapter extends XmlAdapter<String, Set<String>> { | ||
|
||
@Override | ||
public String marshal(Set<String> bt) { | ||
return String.join(",", bt); | ||
} | ||
|
||
@Override | ||
public Set<String> unmarshal(String vt) { | ||
return new HashSet<>(Arrays.asList(vt.split(","))); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/com/github/agadar/nationstates/adapter/HappeningSpecializationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.github.agadar.nationstates.adapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
import java.util.stream.Collectors; | ||
|
||
import com.github.agadar.nationstates.domain.common.happening.Happening; | ||
import com.github.agadar.nationstates.happeningspecializer.ChangeHappeningSpecializer; | ||
import com.github.agadar.nationstates.happeningspecializer.DispatchHappeningSpecializer; | ||
import com.github.agadar.nationstates.happeningspecializer.EjectedHappeningSpecializer; | ||
import com.github.agadar.nationstates.happeningspecializer.EmbassyHappeningSpecializer; | ||
import com.github.agadar.nationstates.happeningspecializer.IHappeningSpecializer; | ||
import com.github.agadar.nationstates.happeningspecializer.LawHappeningSpecializer; | ||
|
||
/** | ||
* Takes a collection of happenings and returns a sorted set containing those | ||
* same happenings, specialized to corresponding subclasses where applicable. | ||
* | ||
* @author Agadar (https://github.com/Agadar/) | ||
* | ||
*/ | ||
public class HappeningSpecializationHelper implements IHappeningSpecializer<Happening> { | ||
|
||
private static List<IHappeningSpecializer> happeningSpecializers; | ||
private static HappeningSpecializationHelper instance; | ||
|
||
static { | ||
happeningSpecializers = new ArrayList<>(); | ||
happeningSpecializers.add(new ChangeHappeningSpecializer()); | ||
happeningSpecializers.add(new DispatchHappeningSpecializer()); | ||
happeningSpecializers.add(new EjectedHappeningSpecializer()); | ||
happeningSpecializers.add(new EmbassyHappeningSpecializer()); | ||
happeningSpecializers.add(new LawHappeningSpecializer()); | ||
instance = new HappeningSpecializationHelper(); | ||
} | ||
|
||
/** | ||
* Takes a collection of happenings and returns a sorted set containing those | ||
* same happenings, specialized to corresponding subclasses where applicable. | ||
* | ||
* @param happenings | ||
* @return | ||
*/ | ||
public static SortedSet<Happening> specializeHappenings(Collection<Happening> happenings) { | ||
if (happenings == null) { | ||
return null; | ||
} | ||
return new TreeSet(happenings.stream() | ||
.map(happening -> happeningSpecializers.stream() | ||
.filter(specializer -> specializer.isOfSpecializedType(happening)).findAny().orElse(instance) | ||
.toSpecializedType(happening)) | ||
.collect(Collectors.toSet())); | ||
} | ||
|
||
@Override | ||
public boolean isOfSpecializedType(Happening happening) { | ||
throw new UnsupportedOperationException("This method should not have been called"); | ||
} | ||
|
||
@Override | ||
public Happening toSpecializedType(Happening happening) { | ||
return happening; | ||
} | ||
|
||
} |
23 changes: 0 additions & 23 deletions
23
src/main/java/com/github/agadar/nationstates/domain/DailyDumpNations.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/main/java/com/github/agadar/nationstates/domain/DailyDumpRegions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.