-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the validator for Adapter Patterns
- Loading branch information
Showing
14 changed files
with
209 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...tterns-business/src/main/java/org/landy/business/validation/adapter/ValidatorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.landy.business.validation.adapter; | ||
|
||
import org.landy.business.domain.detail.RequestDetail; | ||
import org.landy.business.domain.file.RequestFile; | ||
import org.landy.business.validation.Validator; | ||
import org.landy.business.validation.ValidatorChain; | ||
import org.landy.exception.BusinessValidationException; | ||
|
||
/** | ||
* @author: landy | ||
* @date: 2019/5/19 14:48 | ||
* @description: | ||
*/ | ||
public abstract class ValidatorAdapter implements Validator<RequestDetail, RequestFile> { | ||
|
||
public String doValidate(RequestDetail detail, RequestFile file, ValidatorChain chain) throws BusinessValidationException { | ||
boolean isValid = this.doValidate(detail, file); | ||
//校验失败了,就直接返回 | ||
if(!isValid) { | ||
if(detail.getValidationResult() != null) { | ||
return detail.getValidationResult().getResultMsg(); | ||
} | ||
} | ||
//否则往责任链中下一个校验器进行处理 | ||
return chain.doValidate(detail, file); | ||
} | ||
|
||
@Override | ||
public boolean doValidate(RequestDetail detail, RequestFile file) throws BusinessValidationException { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.