@@ -30,7 +30,17 @@ public interface VerificationResult {
3030 * @return a success result
3131 */
3232 static VerificationResult success () {
33- return DefaultImpl .SUCCESS ;
33+ return new VerificationResult () {
34+ @ Override
35+ public boolean isSuccess () {
36+ return true ;
37+ }
38+
39+ @ Override
40+ public List <String > getErrors () {
41+ return Collections .emptyList ();
42+ }
43+ };
3444 }
3545
3646 /**
@@ -40,37 +50,17 @@ static VerificationResult success() {
4050 * @return a failure result
4151 */
4252 static VerificationResult failure (String ... errors ) {
43- return new DefaultImpl (errors );
44- }
45-
46- /**
47- * Default hidden implementation inside the interface.
48- */
49- class DefaultImpl implements VerificationResult {
50- private static final VerificationResult SUCCESS = new DefaultImpl ();
51-
52- private final List <String > errors ;
53-
54- private DefaultImpl (String ... errors ) {
55- this .errors = Collections .unmodifiableList (errors != null ?
56- Arrays .asList (errors ) : Collections .emptyList ());
57- }
58-
59- @ Override
60- public boolean isSuccess () {
61- return errors .isEmpty ();
62- }
63-
64- @ Override
65- public List <String > getErrors () {
66- return errors ;
67- }
53+ return new VerificationResult () {
54+ @ Override
55+ public boolean isSuccess () {
56+ return errors == null ;
57+ }
6858
69- @ Override
70- public String toString () {
71- return isSuccess ()
72- ? "VerificationResult{success}"
73- : "VerificationResult{errors=" + errors + "}" ;
74- }
59+ @ Override
60+ public List < String > getErrors () {
61+ return Collections . unmodifiableList ( errors != null
62+ ? Arrays . asList ( errors ) : Collections . emptyList ());
63+ }
64+ };
7565 }
76- }
66+ }
0 commit comments