Java tutorial
/* * Project: guahao-portal-biz-core * * File Created at 2014-5-29 * * Copyright 2012 Greenline.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Greenline Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Greenline.com. */ package com.greenline.guahao.biz.manager.customer.validator; import org.apache.commons.lang.StringUtils; import com.greenline.common.util.RegexUtil; import com.greenline.guahao.biz.manager.common.LocalResponseDO; import com.greenline.guahao.biz.manager.common.LocalResponseDO.LocalResponseCode; import com.greenline.guahao.biz.manager.customer.dataobject.CustomerDO; /** * @Type CustomerValidator * @Desc ? * @author alex * @date 2014-5-29 * @Version V1.0 */ public class CustomerValidator { public static boolean validateCustomerDO(LocalResponseDO<Object> lrd, CustomerDO customer) { boolean suc = false; String err = null; if (null == customer) { err = "?"; } else { if (StringUtils.isBlank(customer.getExtUserId())) { err = "?"; } else if (StringUtils.isBlank(customer.getName())) { err = "??"; } else if (StringUtils.isBlank(customer.getIdcard())) { err = "?"; } else if (!RegexUtil.isIdCard(customer.getIdcard().toLowerCase())) { err = "???"; } else if (StringUtils.isBlank(customer.getMobile())) { err = "?"; } else if (!RegexUtil.isMobile(customer.getMobile())) { err = "???"; } else if (null != customer.getSex()) { if (customer.getSex().intValue() != 1 && customer.getSex().intValue() != 2) { lrd.addWarn("?"); customer.setSex(null); } } } if (null != err) { lrd.setResult(LocalResponseCode.LOCAL_ERROR, err, String.format("?%s", err)); } else { suc = true; } return suc; } }