comparison src/org/tmatesoft/hg/repo/HgPhase.java @ 474:09f2d38ecf26

Tests for phases support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 12 Jul 2012 15:36:21 +0200
parents d0e5dc3cae6e
children 5afc7eedb3dd
comparison
equal deleted inserted replaced
473:5c09a9f2e073 474:09f2d38ecf26
24 */ 24 */
25 public enum HgPhase { 25 public enum HgPhase {
26 26
27 Public("public"), Draft("draft"), Secret("secret"), Undefined(""); 27 Public("public"), Draft("draft"), Secret("secret"), Undefined("");
28 28
29 @SuppressWarnings("unused")
30 private final String hgString; 29 private final String hgString;
31 30
32 private HgPhase(String stringRepresentation) { 31 private HgPhase(String stringRepresentation) {
33 hgString = stringRepresentation; 32 hgString = stringRepresentation;
34 } 33 }
43 case 1 : return Draft; 42 case 1 : return Draft;
44 case 2 : return Secret; 43 case 2 : return Secret;
45 } 44 }
46 throw new IllegalArgumentException(String.format("Bad phase index: %d", value)); 45 throw new IllegalArgumentException(String.format("Bad phase index: %d", value));
47 } 46 }
47
48 public static HgPhase parse(String value) {
49 if (Public.hgString.equals(value)) {
50 return Public;
51 }
52 if (Draft.hgString.equals(value)) {
53 return Draft;
54 }
55 if (Secret.hgString.equals(value)) {
56 return Secret;
57 }
58 throw new IllegalArgumentException(String.format("Bad phase name: %d", value));
59 }
48 } 60 }