Add ILLEGAL enum constant to VersionParser.CharType
This commit is contained in:
parent
2233bdf503
commit
7d8b74608f
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user