1 package com.atlassian.webtest.ui.keys;
2
3 import com.google.common.base.Preconditions;
4
5 import static com.google.common.base.Preconditions.checkNotNull;
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class DefaultCharacterKey implements CharacterKey
20 {
21 private final String string;
22 private final char codeUnit;
23
24 public DefaultCharacterKey(String string)
25 {
26 this.string = checkNotNull(string, "string");
27 Preconditions.checkArgument(string.length() == 1, "string should be of length 1");
28 this.codeUnit = string.charAt(0);
29 }
30
31 public DefaultCharacterKey(char codeUnit)
32 {
33 this.codeUnit = codeUnit;
34 this.string = Character.toString(codeUnit);
35 }
36
37 public String string()
38 {
39 return string;
40 }
41
42 public char codeUnit()
43 {
44 return codeUnit;
45 }
46
47 @Override
48 public String toString()
49 {
50 return string;
51 }
52 }