Rename VersionParser.Char to VersionParser.CharType

This commit is contained in:
Zafar Khaja 2013-12-03 22:16:48 +04:00
parent 8fd8b46188
commit a284c5edf2
2 changed files with 9 additions and 9 deletions

View File

@ -27,7 +27,7 @@ import com.github.zafarkhaja.semver.util.Stream;
import com.github.zafarkhaja.semver.util.UnexpectedElementException; import com.github.zafarkhaja.semver.util.UnexpectedElementException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.github.zafarkhaja.semver.VersionParser.Char.*; import static com.github.zafarkhaja.semver.VersionParser.CharType.*;
/** /**
* A parser for the SemVer Version. * A parser for the SemVer Version.
@ -40,7 +40,7 @@ class VersionParser implements Parser<Version> {
/** /**
* Valid character types. * Valid character types.
*/ */
static enum Char implements Stream.ElementType<Character> { static enum CharType implements Stream.ElementType<Character> {
DIGIT { DIGIT {
/** /**
@ -279,8 +279,8 @@ class VersionParser implements Parser<Version> {
* @throws GrammarException if the pre-release version has empty identifier(s) * @throws GrammarException if the pre-release version has empty identifier(s)
*/ */
private MetadataVersion parsePreRelease() { private MetadataVersion parsePreRelease() {
Char end = closestEndpoint(PLUS, EOL); CharType end = closestEndpoint(PLUS, EOL);
Char before = closestEndpoint(DOT, end); CharType before = closestEndpoint(DOT, end);
List<String> idents = new ArrayList<String>(); List<String> idents = new ArrayList<String>();
while (!chars.positiveLookahead(end)) { while (!chars.positiveLookahead(end)) {
if (before == DOT) { if (before == DOT) {
@ -320,8 +320,8 @@ class VersionParser implements Parser<Version> {
* @throws GrammarException if the build metadata has empty identifier(s) * @throws GrammarException if the build metadata has empty identifier(s)
*/ */
private MetadataVersion parseBuild() { private MetadataVersion parseBuild() {
Char end = EOL; CharType end = EOL;
Char before = closestEndpoint(DOT, end); CharType before = closestEndpoint(DOT, end);
List<String> idents = new ArrayList<String>(); List<String> idents = new ArrayList<String>();
while (!chars.positiveLookahead(end)) { while (!chars.positiveLookahead(end)) {
if (before == DOT) { if (before == DOT) {
@ -417,7 +417,7 @@ class VersionParser implements Parser<Version> {
* @param orThis the character to fallback to * @param orThis the character to fallback to
* @return the closest character * @return the closest character
*/ */
private Char closestEndpoint(Char tryThis, Char orThis) { private CharType closestEndpoint(CharType tryThis, CharType orThis) {
if (chars.positiveLookaheadBefore(orThis, tryThis)) { if (chars.positiveLookaheadBefore(orThis, tryThis)) {
return tryThis; return tryThis;
} }

View File

@ -24,14 +24,14 @@
package com.github.zafarkhaja.semver; package com.github.zafarkhaja.semver;
import org.junit.Test; import org.junit.Test;
import static com.github.zafarkhaja.semver.VersionParser.Char.*; import static com.github.zafarkhaja.semver.VersionParser.CharType.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* *
* @author Zafar Khaja <zafarkhaja@gmail.com> * @author Zafar Khaja <zafarkhaja@gmail.com>
*/ */
public class VersionParserCharTest { public class VersionParserCharTypeTest {
@Test @Test
public void shouldBeMatchedByDigit() { public void shouldBeMatchedByDigit() {