Package org.eweb4j.mvc.config.creator

Source Code of org.eweb4j.mvc.config.creator.EqualsImpl

package org.eweb4j.mvc.config.creator;

import org.eweb4j.mvc.config.bean.FieldConfigBean;
import org.eweb4j.mvc.config.bean.ParamConfigBean;
import org.eweb4j.mvc.config.bean.ValidatorConfigBean;
import org.eweb4j.mvc.validator.ValidatorConstant;
import org.eweb4j.mvc.validator.annotation.EqualsVal;


public class EqualsImpl implements ValidatorCreator {

  private EqualsVal ann;

  public EqualsImpl(EqualsVal ann) {
    this.ann = ann;
  }

  public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
      return null;
    if (val == null || !ValidatorConstant.EQUALS_VAL.equals(val.getName())) {
      val = new ValidatorConfigBean();
      val.setName(ValidatorConstant.EQUALS_VAL);
    }

    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(ann.mess());
    ParamConfigBean pcb = new ParamConfigBean();
    pcb.setName(ValidatorConstant.EQUALS_TO_PARAM);
    pcb.setValue(ann.to());
    fcb.getParam().add(pcb);

    val.getField().add(fcb);

    return val;
  }

}
TOP

Related Classes of org.eweb4j.mvc.config.creator.EqualsImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.