Java 类javax.validation.constraints.AssertTrue 实例源码
项目:open-Autoscaler
文件:specificDate.java
@AssertTrue(message="{specificDate.isDateTimeValid.AssertTrue}")
private boolean isDateTimeValid() {
try {
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
dateformat.setLenient(false);
ParsePosition position = new ParsePosition(0);
String firstDateTime = this.startDate + " " + this.startTime;
String secondDateTime = this.endDate + " " + this.endTime;
Date first = dateformat.parse(firstDateTime, position);
if (( first == null) || (position.getIndex() != firstDateTime.length()))
return false;
position = new ParsePosition(0);
Date second = dateformat.parse(secondDateTime, position);
if (( second == null) || (position.getIndex() != secondDateTime.length()))
return false;
return first.before(second);
} catch (Exception e) {
BeanValidation.logger.info(e.getMessage());
return false;
}
}
项目:oma-riista-web
文件:AddressDTO.java
@AssertTrue
@JsonIgnore
public boolean isValidAddress() {
return StringUtils.hasText(streetAddress)
&& StringUtils.hasText(postalCode)
&& StringUtils.hasText(city);
}
项目:open-Autoscaler
文件:recurringSchedule.java
@AssertTrue(message="{recurringSchedule.isRepeatOnValid.AssertTrue}")
private boolean isRepeatOnValid() {
String[] s_values = this.repeatOn.replace("\"", "").replace("[", "").replace("]", "").split(",");
String[] weekday = {"1", "2", "3", "4", "5", "6", "7"};
List<String> weekday_list = Arrays.asList(weekday);
Set<String> validValues = new HashSet<String>(weekday_list);
List<String> value_list = Arrays.asList(s_values);
Set<String> value_set = new HashSet<String>(value_list);
if ( s_values.length > value_set.size()) {
return false;
}
for (String s: s_values){
if(!validValues.contains(s)) {
return false;
}
}
if ( s_values.length > validValues.size()) {
return false;
}
return true;
}
项目:open-Autoscaler
文件:recurringSchedule.java
@AssertTrue(message="{recurringSchedule.isTimeValid.AssertTrue}")
private boolean isTimeValid() {
try {
SimpleDateFormat parser = new SimpleDateFormat("HH:mm");
parser.setLenient(false);
ParsePosition position = new ParsePosition(0);
Date start_time = parser.parse(this.startTime, position);
if (( start_time == null) || (position.getIndex() != this.startTime.length()))
return false;
position = new ParsePosition(0);
Date end_time = parser.parse(this.endTime, position);
if (( end_time == null) || (position.getIndex() != this.endTime.length()))
return false;
return start_time.before(end_time);
} catch (Exception e) {
return false;
}
}
项目:minijax
文件:MinijaxConstraintDescriptor.java
private static MinijaxConstraintDescriptor<AssertTrue> buildAssertTrueValidator(final AssertTrue assertTrue, final Class<?> valueClass) {
if (valueClass == boolean.class || valueClass == Boolean.class) {
return new MinijaxConstraintDescriptor<>(assertTrue, AssertTrueValidator.INSTANCE);
}
throw new ValidationException("Unsupported type for @AssertTrue annotation: " + valueClass);
}
项目:randomito-all
文件:AssertTrueAnnotationPostProcessor.java
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
if (!ctx.isAnnotationPresent(AssertTrue.class)) {
return value;
}
return true;
}
项目:oma-riista-web
文件:BasicClubHuntingSummary.java
@AssertTrue
public boolean isPresenceOfHarvestCountsConsistentWithModeratorOverride() {
final Object[] harvestCounts = {
numberOfAdultMales, numberOfAdultFemales, numberOfYoungMales, numberOfYoungFemales,
numberOfNonEdibleAdults, numberOfNonEdibleYoungs
};
// When moderator-override flag is true then all harvest count fields must be non-null
// and vice versa.
return moderatorOverride ? F.allNotNull(harvestCounts) : F.allNull(harvestCounts);
}
项目:steve-plugsurfing
文件:AbstractChangeConfigurationParams.java
@AssertTrue(message = "Custom Configuration Key cannot be left blank")
public boolean isValidCustom() {
if (keyType == ConfigurationKeyType.CUSTOM) {
return !Strings.isNullOrEmpty(customConfKey);
} else {
return true;
}
}
项目:steve-plugsurfing
文件:AbstractChangeConfigurationParams.java
@AssertTrue(message = "Configuration Key is required")
public boolean isValidPredefined() {
if (keyType == ConfigurationKeyType.PREDEFINED) {
return getPredefinedKey() != null;
} else {
return true;
}
}
项目:steve-plugsurfing
文件:StationForm.java
@AssertTrue(message = "PlugSurfing requires the number of connectors")
public boolean isValidNumberOfConnections() {
if (plugSurfing) {
return numberOfConnectors != null && numberOfConnectors > 0;
} else {
return true;
}
}
项目:steve-plugsurfing
文件:StationForm.java
@AssertTrue(message = "PlugSurfing requires latitude and longitude values")
public boolean isLocationEmpty() {
if (plugSurfing) {
return getLocationLatitude() != null && getLocationLongitude() != null;
} else {
return true;
}
}
项目:steve-plugsurfing
文件:StationForm.java
@AssertTrue(message = "PlugSurfing requires a city")
public boolean isValidCity() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getAddress().getCity());
} else {
return true;
}
}
项目:java-di
文件:GenieTest.java
@Test
public void testRegisteredPostConstructProcessor() {
genie.registerPostConstructProcessor(AssertTrue.class, new AssertTrueHandler());
yes(genie.get(FooToPass.class).val);
try {
genie.get(FooToFail.class);
fail("Expect ValidationException here");
} catch (ValidationException e) {
// test pass
}
}
项目:steve-plugsurfing
文件:StationForm.java
@AssertTrue(message = "PlugSurfing requires a street name")
public boolean isValidStreetName() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getAddress().getStreet());
} else {
return true;
}
}
项目:steve-plugsurfing
文件:StationForm.java
@AssertTrue(message = "PlugSurfing requires non-empty phone number")
public boolean isValidPhone() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getContact().getPhone());
} else {
return true;
}
}
项目:geeMVC-Java-MVC-Framework
文件:AssertTrueValidationAdapter.java
@Override
public void validate(AssertTrue assertTrueAnnotation, String name, ValidationContext validationCtx, Errors errors) {
Object value = validationCtx.value(name);
boolean isFalse = false;
if (value != null && value instanceof Boolean)
isFalse = Boolean.TRUE.equals(value);
if (!isFalse)
errors.add(name, assertTrueAnnotation.message(), value);
}
项目:backstopper
文件:ReflectionMagicWorksTest.java
@AssertTrue(message = "I am a constructor annotated with a constraint even though it doesn't really make sense")
public DifferentValidationAnnotationOptions(String nonAnnotatedConstructorParam,
@NotNull(message = "I am a constructor param annotated with a constraint 1") String annotatedConstructorParam1,
@NotNull(message = "I am a constructor param annotated with a constraint 2") String annotatedConstructorParam2,
String alsoNotAnnotatedConstructorParam) {
}
项目:open-Autoscaler
文件:HistoryData.java
@AssertTrue(message="{HistoryData.isTimeZoneValid.AssertTrue}")
private boolean isTimeZoneValid() {
Set<String> timezoneset = new HashSet<String>(Arrays.asList(Constants.timezones));
if(timezoneset.contains(this.timeZone))
return true;
return false;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{PolicyTrigger.ismetricTypeValid.AssertTrue}")
private boolean isMetricTypeValid() {
for (PolicyTrigger trigger : this.policyTriggers){
if ((trigger.metricType == null) || (!(Arrays.asList(Constants.metrictype).contains(trigger.metricType))))
return false;
}
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{Policy.isMetricTypeValid.AssertTrue}")
private boolean isMetricTypeUnique() {
Set<String> metric_types = new HashSet<String>();
for (PolicyTrigger trigger : this.policyTriggers){
metric_types.add(trigger.metricType);
}
if (metric_types.size() != this.policyTriggers.size())
return false;
else
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{PolicyTrigger.isInstanceStepCountUpValid.AssertTrue}")
private boolean isInstanceStepCountUpValid() { //debug we support count instead of percent change only currently
for (PolicyTrigger trigger : this.policyTriggers){
if (trigger.instanceStepCountUp > (instanceMaxCount -1))
return false;
}
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{PolicyTrigger.isInstanceStepCountDownValid.AssertTrue}")
private boolean isInstanceStepCountDownValid() { //debug we support count instead of percent change only currently
for (PolicyTrigger trigger : this.policyTriggers){
if (trigger.instanceStepCountDown > instanceMaxCount)
return false;
}
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{Policy.isMetricTypeMatched.AssertTrue}")
private boolean isMetricTypeSupported() {
String [] supported_metrics = Constants.getMetricTypeByAppType(this.appType);
BeanValidation.logger.info("supported metrics are: " + Arrays.toString(supported_metrics));
if (supported_metrics != null) {
for (PolicyTrigger trigger : this.policyTriggers) {
if (!(Arrays.asList(supported_metrics).contains(trigger.metricType)))
return false;
}
}
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{Policy.isRecurringScheduleTimeValid.AssertTrue}")
private boolean isRecurringScheduleTimeValid() {
if ((this.schedules != null) && (RecurringScheduleTimeValid(this.schedules.recurringSchedule) == false)) {
return false;
}
return true;
}
项目:open-Autoscaler
文件:TransferedPolicy.java
@AssertTrue(message="{Policy.isSpecificDateTimeValid.AssertTrue}")
private boolean isSpecificDateTimeValid() {
if ((this.schedules != null) && (SpecificDateTimeValid(this.schedules.specificDate) == false)) {
return false;
}
return true;
}
项目:open-Autoscaler
文件:specificDate.java
@AssertTrue(message="{specificDate.isInstCountValid.AssertTrue}")
private boolean isInstCountValid() {
if (this.maxInstCount > 0) { //maxInstCount is set
if (this.minInstCount > this.maxInstCount) {
return false;
}
}
return true;
}
项目:open-Autoscaler
文件:recurringSchedule.java
@AssertTrue(message="{recurringSchedule.isInstCountValid.AssertTrue}")
private boolean isInstCountValid() {
if (this.maxInstCount > 0) { //maxInstCount is set
if (this.minInstCount > this.maxInstCount) {
return false;
}
}
return true;
}
项目:open-Autoscaler
文件:Schedule.java
@AssertTrue(message="{Schedule.isTimeZoneValid.AssertTrue}") //debug
private boolean isTimeZoneValid() {
if ((null != this.timezone) && (this.timezone.trim().length() != 0)) {
BeanValidation.logger.debug("In schedules timezone is " + this.timezone);//debug
Set<String> timezoneset = new HashSet<String>(Arrays.asList(Constants.timezones));
if(timezoneset.contains(this.timezone))
return true;
else
return false;
}
else {
BeanValidation.logger.debug("timezone is empty in schedules");//debug
return false; //timezone must be specified in Schedule
}
}
项目:open-Autoscaler
文件:Schedule.java
@AssertTrue(message="{Schedule.isScheduleValid.AssertTrue}") //debug
private boolean isScheduleValid() {
if (((null == this.recurringSchedule) || (this.recurringSchedule.size() == 0) ) && ((null == this.specificDate) || (this.specificDate.size() == 0)) ){
return false; //at least one setting should be exist
}
return true;
}
项目:Voting_1b
文件:ChangePass.java
@AssertTrue(message = "Las claves no coinciden")
public boolean isClavesCoinciden() {
if (claveNueva != null && confirmacionClave != null) {
return claveNueva.equals(confirmacionClave);
}
return false;
}
项目:dss-demonstrations
文件:SignatureDocumentForm.java
@AssertTrue(message = "{error.to.sign.file.mandatory}")
public boolean isDocumentToSign() {
return (documentToSign != null) && (!documentToSign.isEmpty());
}
项目:dss-demonstrations
文件:ExtensionForm.java
@AssertTrue(message = "{error.signed.file.mandatory}")
public boolean isSignedFile() {
return (signedFile != null) && (!signedFile.isEmpty());
}
项目:dss-demonstrations
文件:ValidationForm.java
@AssertTrue(message = "{error.signed.file.mandatory}")
public boolean isSignedFile() {
return (signedFile != null) && (!signedFile.isEmpty());
}
项目:dss-demonstrations
文件:SignatureMultipleDocumentsForm.java
@AssertTrue(message = "{error.to.sign.files.mandatory}")
public boolean isDocumentsToSign() {
return Utils.isCollectionNotEmpty(documentsToSign);
}
项目:dss-demonstrations
文件:CertificateForm.java
@AssertTrue(message = "{error.certificate.mandatory}")
public boolean isCertificateFile() {
return (certificateFile != null) && (!certificateFile.isEmpty());
}
项目:RestAndSpringMVC-CodingChallenge
文件:ConverterFormModel.java
@AssertTrue
public boolean isDataCorrect() {
return type.equals("current") || !date.isEmpty();
}
项目:theskeleton
文件:UpdatePasswordForm.java
@AssertTrue(message="Confirm password should match")
public boolean isValid() {
return this.password.equals(this.cpassword);
}
项目:minijax
文件:MinijaxConstraintDescriptor.java
@SuppressWarnings("unchecked")
public static <T extends Annotation> MinijaxConstraintDescriptor<T> build(final AnnotatedType annotatedType, final T annotation) {
final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
if (constraint == null) {
return null;
}
final Class<?> valueClass = ReflectionUtils.getRawType(annotatedType);
final Class<?> annotationClass = annotation.annotationType();
if (constraint.validatedBy().length > 0) {
return buildDeclaredValidator(annotation, constraint.validatedBy()[0]);
} else if (annotationClass == AssertFalse.class) {
return (MinijaxConstraintDescriptor<T>) buildAssertFalseValidator((AssertFalse) annotation, valueClass);
} else if (annotationClass == AssertTrue.class) {
return (MinijaxConstraintDescriptor<T>) buildAssertTrueValidator((AssertTrue) annotation, valueClass);
} else if (annotationClass == Max.class) {
return (MinijaxConstraintDescriptor<T>) buildMaxValidator((Max) annotation, valueClass);
} else if (annotationClass == Min.class) {
return (MinijaxConstraintDescriptor<T>) buildMinValidator((Min) annotation, valueClass);
} else if (annotationClass == NotBlank.class) {
return (MinijaxConstraintDescriptor<T>) buildNotBlankValidator((NotBlank) annotation, valueClass);
} else if (annotationClass == NotEmpty.class) {
return (MinijaxConstraintDescriptor<T>) buildNotEmptyValidator((NotEmpty) annotation, valueClass);
} else if (annotationClass == NotNull.class) {
return (MinijaxConstraintDescriptor<T>) buildNotNullValidator((NotNull) annotation);
} else if (annotationClass == Pattern.class) {
return (MinijaxConstraintDescriptor<T>) buildPatternValidator((Pattern) annotation, valueClass);
} else if (annotationClass == Size.class) {
return (MinijaxConstraintDescriptor<T>) buildSizeValidator((Size) annotation, valueClass);
} else {
throw new ValidationException("Unrecognized constraint annotation: " + annotation);
}
}
项目:minijax
文件:Car.java
@AssertTrue
public boolean isRegistered() {
return isRegistered;
}
项目:minijax
文件:Car.java
@AssertTrue
public boolean isRegistered() {
return isRegistered;
}