java类javax.validation.constraints.Min的实例源码

UserRestService.java 文件源码 项目:dubbocloud 阅读 18 收藏 0 点赞 0 评论 0
@GET
@Path("{id : ${symbol_escape}${symbol_escape}d+}")
public User getUser(@Min(value = 1L, message = "User ID must be greater than 1") @PathParam("id") Long id/*, @Context HttpServletRequest request*/);
UserRestService.java 文件源码 项目:dubbox-hystrix 阅读 20 收藏 0 点赞 0 评论 0
@GET
@Path("{id : \\d+}")
public User getUser(@Min(value=1L, message="User ID must be greater than 1") @PathParam("id") Long id/*, @Context HttpServletRequest request*/) ;
MoviePersistenceServiceImpl.java 文件源码 项目:REST-Web-Services 阅读 31 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Override
public void saveRating(
        @NotNull @Valid final Rate rate,
        @Min(1) final Long movieId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with rate {}, movieId {}, userId {}", rate, movieId, userId);

    final UserEntity user = this.findUser(userId);
    final MovieEntity movie = this.findMovie(movieId, DataStatus.ACCEPTED);

    final List<MovieReleaseDateEntity> releaseDates = movie.getReleaseDates();

    Lists.newArrayList(releaseDates).sort(Comparator.comparing(MovieReleaseDateEntity::getDate));

    if(!releaseDates.isEmpty()
            && new Date().before(releaseDates.iterator().next().getDate())) {
        throw new ResourceConflictException("The movie with id " + movieId + " had no premiere");
    }

    boolean rated = false;

    final List<MovieRateEntity> ratings = movie.getRatings();
    for(final MovieRateEntity mRate : ratings) {
        if(mRate.getUser().getUniqueId().equals(userId)) {
            mRate.setRate(rate.getRate());

            movie.setRating(this.calculationRating(ratings));

            rated = true;

            break;
        }
    }

    if(!rated) {
        final MovieRateEntity movieRate = new MovieRateEntity();
        movieRate.setRate(rate.getRate());
        movieRate.setMovie(movie);
        movieRate.setUser(user);

        movie.getRatings().add(movieRate);

        movie.setRating(this.calculationRating(movie.getRatings()));
    }
}
AnotherUserRestService.java 文件源码 项目:dubbo2 阅读 16 收藏 0 点赞 0 评论 0
@GET
@Path("{id : \\d+}")
User getUser(@PathParam("id") @Min(1L) Long id);
ValidatorUtilTest.java 文件源码 项目:beanvalidation 阅读 17 收藏 0 点赞 0 评论 0
@Test
public void testAssertViolatedWithViolationAnnotation() {
    testBean.setNumber(0);
    ValidationTestHelper.assertViolated(Min.class, testBean);
}
ValidatorUtilTest.java 文件源码 项目:beanvalidation 阅读 16 收藏 0 点赞 0 评论 0
@Test
public void testAssertViolatedWithViolationAnnotationAndProperty2() {
    testBean.setNumber(0);
    ValidationTestHelper.assertNotViolated(Min.class, testBean, "name");
}
CreateUserCommand.java 文件源码 项目:onboarding-service 阅读 16 收藏 0 点赞 0 评论 0
@Min(18)
@JsonIgnore
public int getAge() {
  return PersonalCode.getAge(personalCode);
}
ValidatorUtilTest.java 文件源码 项目:beanvalidation 阅读 17 收藏 0 点赞 0 评论 0
@Test(expected = AssertionError.class)
public void testAssertViolatedWithViolationAnnotationAndPropertyException() {
    testBean.setNumber(0);
    ValidationTestHelper.assertNotViolated(Min.class, testBean, "number");
}
MovieContributionPersistenceService.java 文件源码 项目:REST-Web-Services 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Update the contribution status.
 *
 * @param contributionId The contribution ID
 * @param userId The user ID
 * @param status Status for the contribution
 * @param comment Comment for verification
 * @throws ResourceForbiddenException if no permissions
 * @throws ResourceNotFoundException if no contribution found or no user found
 */
void updateContributionStatus(
        @Min(1) final Long contributionId,
        @NotBlank final String userId,
        @NotNull final VerificationStatus status,
        final String comment
) throws ResourceForbiddenException, ResourceNotFoundException;
MovieContributionSearchService.java 文件源码 项目:REST-Web-Services 阅读 15 收藏 0 点赞 0 评论 0
/**
 * Search for contributions which match the given filter criteria. Null or empty parameters are ignored.
 *
 * @param id  The movie ID
 * @param field  The movie's field
 * @param status  The contribution's status
 * @param fromDate  Min date of the contribution
 * @param toDate  Max date of the contribution
 * @param page  The page to get
 * @return All the contributions matching the criteria
 * @throws ResourceNotFoundException if no movie found
 */
Page<ContributionSearchResult> findContributions(
        @Nullable @Min(1) final Long id,
        @Nullable final MovieField field,
        @Nullable final DataStatus status,
        @Nullable final Date fromDate,
        @Nullable final Date toDate,
        @NotNull final Pageable page
) throws ResourceNotFoundException;


问题


面经


文章

微信
公众号

扫码关注公众号