[jsemver] 75/95: Add ILLEGAL enum constant to VersionParser.CharType
Alexandre Viau
reazem-guest at moszumanska.debian.org
Mon Feb 16 14:58:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
reazem-guest pushed a commit to branch master
in repository jsemver.
commit 7d8b74608ff4f2508e0f0af5f87a0bf0751fe8b5
Author: Zafar Khaja <zafarkhaja at gmail.com>
Date: Tue Jan 28 12:21:33 2014 +0400
Add ILLEGAL enum constant to VersionParser.CharType
---
.../java/com/github/zafarkhaja/semver/VersionParser.java | 16 ++++++++++++++++
.../zafarkhaja/semver/VersionParserCharTypeTest.java | 8 ++++++++
2 files changed, 24 insertions(+)
diff --git a/src/main/java/com/github/zafarkhaja/semver/VersionParser.java b/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
index 1911e61..25d1c5f 100644
--- a/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
+++ b/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
@@ -26,6 +26,7 @@ package com.github.zafarkhaja.semver;
import com.github.zafarkhaja.semver.util.Stream;
import com.github.zafarkhaja.semver.util.UnexpectedElementException;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.List;
import static com.github.zafarkhaja.semver.VersionParser.CharType.*;
@@ -111,6 +112,21 @@ class VersionParser implements Parser<Version> {
public boolean isMatchedBy(Character chr) {
return chr == null;
}
+ },
+ ILLEGAL {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isMatchedBy(Character chr) {
+ EnumSet<CharType> itself = EnumSet.of(ILLEGAL);
+ for (CharType type : EnumSet.complementOf(itself)) {
+ if (type.isMatchedBy(chr)) {
+ return false;
+ }
+ }
+ return true;
+ }
};
}
diff --git a/src/test/java/com/github/zafarkhaja/semver/VersionParserCharTypeTest.java b/src/test/java/com/github/zafarkhaja/semver/VersionParserCharTypeTest.java
index a979436..4eb4d0d 100644
--- a/src/test/java/com/github/zafarkhaja/semver/VersionParserCharTypeTest.java
+++ b/src/test/java/com/github/zafarkhaja/semver/VersionParserCharTypeTest.java
@@ -80,4 +80,12 @@ public class VersionParserCharTypeTest {
assertFalse(EOL.isMatchedBy('a'));
assertFalse(EOL.isMatchedBy('0'));
}
+
+ @Test
+ public void shouldBeMatchedByIllegal() {
+ assertTrue(ILLEGAL.isMatchedBy('!'));
+ assertFalse(ILLEGAL.isMatchedBy('-'));
+ assertFalse(ILLEGAL.isMatchedBy('a'));
+ assertFalse(ILLEGAL.isMatchedBy('0'));
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jsemver.git
More information about the pkg-java-commits
mailing list