本文整理匯總了Java中javax.validation.constraints.AssertTrue類的典型用法代碼示例。如果您正苦於以下問題:Java AssertTrue類的具體用法?Java AssertTrue怎麽用?Java AssertTrue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AssertTrue類屬於javax.validation.constraints包,在下文中一共展示了AssertTrue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isDateTimeValid
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@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;
}
}
示例2: isValidAddress
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue
@JsonIgnore
public boolean isValidAddress() {
return StringUtils.hasText(streetAddress)
&& StringUtils.hasText(postalCode)
&& StringUtils.hasText(city);
}
示例3: isRepeatOnValid
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@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;
}
示例4: isTimeValid
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@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;
}
}
示例5: buildAssertTrueValidator
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
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);
}
示例6: process
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
if (!ctx.isAnnotationPresent(AssertTrue.class)) {
return value;
}
return true;
}
示例7: isPresenceOfHarvestCountsConsistentWithModeratorOverride
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@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);
}
示例8: isValidCustom
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "Custom Configuration Key cannot be left blank")
public boolean isValidCustom() {
if (keyType == ConfigurationKeyType.CUSTOM) {
return !Strings.isNullOrEmpty(customConfKey);
} else {
return true;
}
}
示例9: isValidPredefined
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "Configuration Key is required")
public boolean isValidPredefined() {
if (keyType == ConfigurationKeyType.PREDEFINED) {
return getPredefinedKey() != null;
} else {
return true;
}
}
示例10: isValidNumberOfConnections
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "PlugSurfing requires the number of connectors")
public boolean isValidNumberOfConnections() {
if (plugSurfing) {
return numberOfConnectors != null && numberOfConnectors > 0;
} else {
return true;
}
}
示例11: isLocationEmpty
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "PlugSurfing requires latitude and longitude values")
public boolean isLocationEmpty() {
if (plugSurfing) {
return getLocationLatitude() != null && getLocationLongitude() != null;
} else {
return true;
}
}
示例12: isValidCity
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "PlugSurfing requires a city")
public boolean isValidCity() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getAddress().getCity());
} else {
return true;
}
}
示例13: testRegisteredPostConstructProcessor
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@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
}
}
示例14: isValidStreetName
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "PlugSurfing requires a street name")
public boolean isValidStreetName() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getAddress().getStreet());
} else {
return true;
}
}
示例15: isValidPhone
import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue(message = "PlugSurfing requires non-empty phone number")
public boolean isValidPhone() {
if (plugSurfing) {
return !Strings.isNullOrEmpty(getContact().getPhone());
} else {
return true;
}
}