/* | |
* Copyright 1999-2012 Alibaba Group. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package com.alibaba.dubbo.config.validation; | |
import java.io.Serializable; | |
import java.util.Date; | |
import javax.validation.constraints.Future; | |
import javax.validation.constraints.Max; | |
import javax.validation.constraints.Min; | |
import javax.validation.constraints.NotNull; | |
import javax.validation.constraints.Past; | |
import javax.validation.constraints.Pattern; | |
import javax.validation.constraints.Size; | |
/** | |
* ValidationParameter | |
* | |
* @author william.liangf | |
*/ | |
public class ValidationParameter implements Serializable { | |
private static final long serialVersionUID = 7158911668568000392L; | |
@NotNull // 不允许为空 | |
@Size(min = 1, max = 20) // 长度或大小范围 | |
private String name; | |
@NotNull(groups = ValidationService.Save.class) // 保存时不允许为空,更新时允许为空 ,表示不更新该字段 | |
@Pattern(regexp = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$") | |
private String email; | |
@Min(18) // 最小值 | |
@Max(100) // 最大值 | |
private int age; | |
@Past // 必须为一个过去的时间 | |
private Date loginDate; | |
@Future // 必须为一个未来的时间 | |
private Date expiryDate; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getEmail() { | |
return email; | |
} | |
public void setEmail(String email) { | |
this.email = email; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
public Date getLoginDate() { | |
return loginDate; | |
} | |
public void setLoginDate(Date loginDate) { | |
this.loginDate = loginDate; | |
} | |
public Date getExpiryDate() { | |
return expiryDate; | |
} | |
public void setExpiryDate(Date expiryDate) { | |
this.expiryDate = expiryDate; | |
} | |
} |