本文整理汇总了Java中org.apache.bval.guice.Validate类的典型用法代码示例。如果您正苦于以下问题:Java Validate类的具体用法?Java Validate怎么用?Java Validate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Validate类属于org.apache.bval.guice包,在下文中一共展示了Validate类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.apache.bval.guice.Validate; //导入依赖的package包/类
@Override
protected void configure() {
bindInterceptor(annotatedWith(Api.class), AUTH_MATCHER, new AuthInterceptor());
// We must respect this interceptor order.
bindInterceptor(annotatedWith(Api.class), annotatedWith(Validate.class),
new ValidationTranslationInterceptor());
install(new ValidationModule());
}
示例2: listFiles
import org.apache.bval.guice.Validate; //导入依赖的package包/类
/**
* Returns the paginated list of uploaded files.
*
* @param user the authenticated user.
* @param offset the file list offset.
* @param limit the file list limit.
* @return the paginated list of uploaded files.
*/
@ApiMethod(name = "listFiles", path = "files", httpMethod = HttpMethod.GET)
@Validate
public List<FileData> listFiles(
@Auth User user,
@Named("offset") @DefaultValue("0") @Min(0) int offset,
@Named("limit") @DefaultValue("100") @Min(0) @Max(100) int limit) {
Query q = new Query(Constants.ENTITY_NAME);
PreparedQuery pq = datastore.prepare(q);
Iterable<Entity> entities = pq.asIterable(FetchOptions.Builder.withOffset(offset).limit(limit));
Iterable<FileData> files = Iterables.transform(entities, entityToFileData());
return Lists.newArrayList(files);
}
示例3: startDownload
import org.apache.bval.guice.Validate; //导入依赖的package包/类
@POST
@Validate
public String startDownload(@Valid DownloadRequest request, @Context SecurityContext security) {
LOG.debug("Download: [{}]", request);
// assert authenticated user is the same as in download
assertLoginMatches(request, security);
String downloadKey = requestService.create(request);
LOG.info("Created new download job with key [{}]", downloadKey);
return downloadKey;
}