@@ -24,6 +24,10 @@ public interface CommandResult<T> {
2424
2525 @ NotNull String id ();
2626
27+ default @ Nullable String message () {
28+ return null ;
29+ }
30+
2731 //without context
2832
2933 static <T > @ NotNull SuccessResult <T > successful (int lastInputIndex , @ NotNull CommandNode <?> lastNode , @ Nullable T data ) {
@@ -94,12 +98,12 @@ public interface CommandResult<T> {
9498 return new UnprocessableContentResult <>(lastInputIndex , lastNode );
9599 }
96100
97- static <T > @ NotNull UnauthorizedResult <T > unauthorized (int lastInputIndex , @ NotNull CommandNode <?> lastNode ) {
98- return new UnauthorizedResult <>(lastInputIndex , lastNode );
101+ static <T > @ NotNull UnauthorizedResult <T > unauthorized (int lastInputIndex , @ NotNull CommandNode <?> lastNode , @ Nullable String message ) {
102+ return new UnauthorizedResult <>(lastInputIndex , lastNode , message );
99103 }
100104
101- static <T > @ NotNull ForbiddenResult <T > forbidden (int lastInputIndex , @ NotNull CommandNode <?> lastNode ) {
102- return new ForbiddenResult <>(lastInputIndex , lastNode );
105+ static <T > @ NotNull ForbiddenResult <T > forbidden (int lastInputIndex , @ NotNull CommandNode <?> lastNode , @ Nullable String message ) {
106+ return new ForbiddenResult <>(lastInputIndex , lastNode , message );
103107 }
104108
105109 //with context
@@ -148,11 +152,11 @@ public interface CommandResult<T> {
148152 return unprocessableContent (context .lastInputIndex (), context .lastNode ());
149153 }
150154
151- static <T > @ NotNull UnauthorizedResult <T > unauthorized (@ NotNull CommandContext context ) {
152- return unauthorized (context .lastInputIndex (), context .lastNode ());
155+ static <T > @ NotNull UnauthorizedResult <T > unauthorized (@ NotNull CommandContext context , @ Nullable String message ) {
156+ return unauthorized (context .lastInputIndex (), context .lastNode (), message );
153157 }
154158
155- static <T > @ NotNull ForbiddenResult <T > forbidden (@ NotNull CommandContext context ) {
156- return forbidden (context .lastInputIndex (), context .lastNode ());
159+ static <T > @ NotNull ForbiddenResult <T > forbidden (@ NotNull CommandContext context , @ Nullable String message ) {
160+ return forbidden (context .lastInputIndex (), context .lastNode (), message );
157161 }
158162}
0 commit comments