當前位置: 首頁>>代碼示例>>Java>>正文


Java AssertTrue類代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:cfibmers,項目名稱:open-Autoscaler,代碼行數:22,代碼來源:specificDate.java

示例2: isValidAddress

import javax.validation.constraints.AssertTrue; //導入依賴的package包/類
@AssertTrue
@JsonIgnore
public boolean isValidAddress() {
    return StringUtils.hasText(streetAddress)
            && StringUtils.hasText(postalCode)
            && StringUtils.hasText(city);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:8,代碼來源:AddressDTO.java

示例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;
}
 
開發者ID:cfibmers,項目名稱:open-Autoscaler,代碼行數:24,代碼來源:recurringSchedule.java

示例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;
	}
}
 
開發者ID:cfibmers,項目名稱:open-Autoscaler,代碼行數:19,代碼來源:recurringSchedule.java

示例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);
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:8,代碼來源:MinijaxConstraintDescriptor.java

示例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;
}
 
開發者ID:randomito,項目名稱:randomito-all,代碼行數:8,代碼來源:AssertTrueAnnotationPostProcessor.java

示例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);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:12,代碼來源:BasicClubHuntingSummary.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:AbstractChangeConfigurationParams.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:AbstractChangeConfigurationParams.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:StationForm.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:StationForm.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:StationForm.java

示例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
    }
}
 
開發者ID:osglworks,項目名稱:java-di,代碼行數:12,代碼來源:GenieTest.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:StationForm.java

示例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;
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:9,代碼來源:StationForm.java


注:本文中的javax.validation.constraints.AssertTrue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。