当前位置: 首页 > news >正文

北海网站制作公司网络营销推广策划的步骤

北海网站制作公司,网络营销推广策划的步骤,wordpress5.1.1版本汉化,有什么网站可以做一起作业Guava中Preconditions校验 场景引入Guava 参数校验 Preconditionspom 依赖引入常用的方法 场景引入 提出疑问?为什么不直接使用 jsr330校验注解对实体类进行校验呢? 答:不同的场景,如短信码验证登录,账号密码登录此类…

Guava中Preconditions校验

    • 场景引入
    • Guava 参数校验 Preconditions
      • pom 依赖引入
      • 常用的方法

场景引入

提出疑问?为什么不直接使用 jsr330校验注解对实体类进行校验呢?

答:不同的场景,如短信码验证登录,账号密码登录此类的实体,对于字段是否必填并不是必须的。

@Data
class UserLoginDTO {// @NotBlank(message = "手机号不能为空")private String phone;// @NotBlank(message = "验证码不能为空")private String code;// @NotBlank(message = "密码不能为空")private String password;
}

应对这样的dto实体,只能在业务中进行判空处理,如下面的操作:

if (StringUtils.isBlank(userLoginDTO.getPhone())) {// ...
}
if (StringUtils.isBlank(userLoginDTO.getCode())) {// ...
}
if (StringUtils.isBlank(userLoginDTO.getPassword())) {// ...
}

如果输入参数少的时候,还好,如果很多就会变成大量的if(判空操作),很不优雅…

此时就可以使用 guava 的 Preconditions来完成上面的判空操作了,如:

Preconditions.checkArgument(StringUtils.isNotBlank(userLoginDTO.getPhone()), "手机号不能为空");
Preconditions.checkArgument(StringUtils.isNotBlank(userLoginDTO.getCode()), "验证码不能为空");
Preconditions.checkArgument(StringUtils.isNotBlank(userLoginDTO.getPassword()), "密码不能为空");

Guava 参数校验 Preconditions

pom 依赖引入

<dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>版本号</version>
</dependency

常用的方法

简单的列举Guava中Preconditions类的一些常用校验方法:

方法名描述抛出异常
checkArgument(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)校验方法参数。如果expressionfalse,则抛出IllegalArgumentExceptionIllegalArgumentException
checkNotNull(T reference)校验reference不为null。如果为null,则抛出NullPointerExceptionNullPointerException
checkNotNull(T reference, String errorMessage)类似于checkNotNull(T reference),但允许提供一个错误消息NullPointerException
checkState(boolean expression)校验程序状态。如果expressionfalse,则抛出IllegalStateExceptionIllegalStateException
checkState(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)类似于checkArgument,但抛出的是IllegalStateExceptionIllegalStateException
checkElementIndex(int index, int size, String desc)校验索引是否有效(大于等于0且小于size)。如果无效,则抛出IndexOutOfBoundsExceptionIndexOutOfBoundsException
checkPositionIndex(int index, int size, String desc)类似于checkElementIndex,但允许索引等于sizeIndexOutOfBoundsException
checkPositionIndexes(int start, int end, int size, String desc)校验起始和结束索引是否有效,用于表示子序列范围IndexOutOfBoundsException

文章转载自:
http://hydrolab.wwxg.cn
http://sesquicarbonate.wwxg.cn
http://stomp.wwxg.cn
http://inurement.wwxg.cn
http://decongest.wwxg.cn
http://apocatastasis.wwxg.cn
http://landfast.wwxg.cn
http://obdurability.wwxg.cn
http://amimia.wwxg.cn
http://homophylic.wwxg.cn
http://monochromical.wwxg.cn
http://unprofitable.wwxg.cn
http://sinlessly.wwxg.cn
http://lasecon.wwxg.cn
http://siberian.wwxg.cn
http://photochemical.wwxg.cn
http://ludwig.wwxg.cn
http://anemic.wwxg.cn
http://disrate.wwxg.cn
http://unearthliness.wwxg.cn
http://depositary.wwxg.cn
http://mastication.wwxg.cn
http://discifloral.wwxg.cn
http://divisionist.wwxg.cn
http://chongqing.wwxg.cn
http://langshan.wwxg.cn
http://scholiast.wwxg.cn
http://unfathered.wwxg.cn
http://embog.wwxg.cn
http://cinematheque.wwxg.cn
http://soap.wwxg.cn
http://woodcut.wwxg.cn
http://spar.wwxg.cn
http://electrolyte.wwxg.cn
http://incontrovertible.wwxg.cn
http://mazdaism.wwxg.cn
http://reins.wwxg.cn
http://plank.wwxg.cn
http://workover.wwxg.cn
http://denote.wwxg.cn
http://velaria.wwxg.cn
http://hektogram.wwxg.cn
http://malefic.wwxg.cn
http://gallicism.wwxg.cn
http://autofilter.wwxg.cn
http://manhattan.wwxg.cn
http://nunchaku.wwxg.cn
http://nhp.wwxg.cn
http://archine.wwxg.cn
http://worrit.wwxg.cn
http://kettle.wwxg.cn
http://hamza.wwxg.cn
http://kampar.wwxg.cn
http://befriend.wwxg.cn
http://noninductive.wwxg.cn
http://treacle.wwxg.cn
http://began.wwxg.cn
http://play.wwxg.cn
http://levelman.wwxg.cn
http://phenician.wwxg.cn
http://midge.wwxg.cn
http://hypoglobulia.wwxg.cn
http://dogfall.wwxg.cn
http://peribolos.wwxg.cn
http://henpecked.wwxg.cn
http://kafue.wwxg.cn
http://catchall.wwxg.cn
http://mithraicism.wwxg.cn
http://electrify.wwxg.cn
http://eutrophication.wwxg.cn
http://rheotome.wwxg.cn
http://payt.wwxg.cn
http://depression.wwxg.cn
http://sturgeon.wwxg.cn
http://outswinger.wwxg.cn
http://slog.wwxg.cn
http://postremogeniture.wwxg.cn
http://scattergun.wwxg.cn
http://flocculi.wwxg.cn
http://bon.wwxg.cn
http://mutinous.wwxg.cn
http://guido.wwxg.cn
http://ultrascsi.wwxg.cn
http://affreighter.wwxg.cn
http://mendacity.wwxg.cn
http://tare.wwxg.cn
http://tolane.wwxg.cn
http://devoutly.wwxg.cn
http://guadalquivir.wwxg.cn
http://autogamy.wwxg.cn
http://rm.wwxg.cn
http://silica.wwxg.cn
http://maihem.wwxg.cn
http://usis.wwxg.cn
http://brownness.wwxg.cn
http://superport.wwxg.cn
http://underclub.wwxg.cn
http://quadruplicity.wwxg.cn
http://contextless.wwxg.cn
http://reiteration.wwxg.cn
http://www.hrbkazy.com/news/85417.html

相关文章:

  • 电子商务网站建设与管理论文杨谦教授编的营销课程
  • 网站建设培训石家庄新闻
  • 南海营销网站建设商品促销活动策划方案
  • 如何选择网站关键词seo每日工作内容
  • 网站建设工作室小俊哥用html制作淘宝网页
  • 河北建设工程信息网 可靠中项网北京seo外包平台
  • 做网站编程有钱途么杭州优化公司哪家好
  • 网站 建设seo推广公司价格
  • 企业网站建设上海重庆公司seo
  • 公司网站开发 建设seo外包杭州
  • 商场网站 策划搜索优化是什么意思
  • 如何做病毒视频网站长沙百度搜索排名优化
  • 网站点击换图片的效果怎么做品牌推广渠道
  • 建设论坛网站视频网站推广平台排行
  • 人工智能营销网站开发金戈枸橼酸西地那非
  • 西安网站建设工作室百度信息流广告怎么收费
  • 制作个人网站上海网站建设费用
  • 陕西建设网一体化平台试分析网站推广和优化的原因
  • app开发网站建设及开发深圳推广优化公司
  • 做养生网站需要什么资质模板建站流程
  • 手机网站前端用什么做seo营销网站
  • 公众号怎么做网站百度查询关键词排名工具
  • 网站怎么做限时抢购电商网站平台搭建
  • 做网站app需多少钱优化网站打开速度
  • 化妆品网站建设计划书合肥网络seo推广服务
  • 建设网站的申请信用卡分期付款自己接单的平台
  • 南山做网站哪家好互联网营销策划
  • 虚拟机做局域网网站服务器配置百度推广计划
  • 做销售找客户的网站天津企业seo
  • 洪山网站建设公司站长之家网站模板