package org.binwang.bard.basic.injector;

import org.binwang.bard.basic.marker.Required;
import org.binwang.bard.core.BindTo;
import org.binwang.bard.core.Injector;
import org.binwang.bard.core.marker.After;
import org.binwang.bard.core.marker.Before;

@BindTo(Required.class)
public class RequiredInjector extends Injector<Required> {
    @Before
    public void validateParam() throws RequiredNullException {
        if (injectorVariable == null) {
            throw new RequiredNullException();
        }
    }

    @After
    public void handleNullRequired() {
        if (context.exception instanceof RequiredNullException) {
            context.exception = null;
            context.result = "should not be null";
        }
    }

    @Override public void generateDoc() {
        docParameter.limitations.put("required", true);
    }


    public static class RequiredNullException extends Exception {
    }
}

@@ -35,16 +35,115 @@
 ector;%0A%0A
+import org.binwang.bard.basic.marker.ErrorCase;%0Aimport org.binwang.bard.basic.marker.HandleErrors;%0A
 import o
@@ -261,51 +261,8 @@
 or;%0A
-import org.binwang.bard.core.marker.After;%0A
 impo
@@ -405,261 +405,216 @@
     
-public void validateParam() throws RequiredNullException %7B%0A        if (injectorVariable == null) %7B%0A            throw new RequiredNullException();%0A        %7D%0A    %7D%0A%0A    @After%0A    public void handleNullRequired() %7B%0A        if (context.exception instanceof
+@HandleErrors(%7B%0A        @ErrorCase(description = %22required param don't in%22,%0A            code = 10001, exception = RequiredNullException.class, logLevel = %22DEBUG%22)%0A    %7D)%0A    public void validateParam() throws
  Req
@@ -631,17 +631,16 @@
 xception
-)
  %7B%0A     
@@ -646,37 +646,39 @@
     
-    context.exception 
+if (injectorVariable =
 = null
-;
+) %7B
 %0A   
@@ -690,45 +690,41 @@
     
-context.result = %22should not be null%22
+throw new RequiredNullException()
 ;%0A  

use HandleError with Required