本文整理汇总了Java中com.google.api.server.spi.config.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于com.google.api.server.spi.config包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParameterAnnotations
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@Test
public void testParameterAnnotations() throws Exception {
@Api
class Endpoint {
@SuppressWarnings("unused")
public void method(@Named("foo") @Nullable @DefaultValue("4") int foo) {}
}
ApiConfig config = createConfig(Endpoint.class);
annotationReader.loadEndpointClass(serviceContext, Endpoint.class, config);
annotationReader.loadEndpointMethods(serviceContext, Endpoint.class,
config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig =
Iterables.getOnlyElement(config.getApiClassConfig().getMethods().values());
ApiParameterConfig parameterConfig =
Iterables.getOnlyElement(methodConfig.getParameterConfigs());
validateParameter(parameterConfig, "foo", true, "4", int.class, null, int.class);
}
示例2: testParameterAnnotations_javax
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@Test
public void testParameterAnnotations_javax() throws Exception {
@Api
class Endpoint {
@SuppressWarnings("unused")
public void method(@javax.inject.Named("foo") @javax.annotation.Nullable int foo) {}
}
ApiConfig config = createConfig(Endpoint.class);
annotationReader.loadEndpointClass(serviceContext, Endpoint.class, config);
annotationReader.loadEndpointMethods(serviceContext, Endpoint.class,
config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig =
Iterables.getOnlyElement(config.getApiClassConfig().getMethods().values());
ApiParameterConfig parameterConfig =
Iterables.getOnlyElement(methodConfig.getParameterConfigs());
validateParameter(parameterConfig, "foo", true, null, int.class, null, int.class);
}
示例3: echo
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(
name = "echo",
path = "echo",
httpMethod = ApiMethod.HttpMethod.GET)
/* >>>>>>>>>>>>>> this is for testing only
* curl -H "Content-Type: application/json" -X GET -d '{"message":"hello world"}' https://cryptonomica-server.appspot.com/_ah/api/userSearchAndViewAPI/v1/echo
* */
public StringWrapperObject echo(
@Named("message") String message,
@Named("n") @Nullable Integer n
) {
StringWrapperObject stringWrapperObject = new StringWrapperObject();
if (n != null && n >= 0) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
if (i > 0) {
sb.append(" ");
}
sb.append(message);
}
stringWrapperObject.setMessage(sb.toString());
}
return stringWrapperObject;
}
示例4: createHIT
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "createHIT", path = "createHIT/{surveyId}", httpMethod = HttpMethod.POST)
public StringResponse createHIT(@Named("surveyId") String surveyId,
@Nullable @Named("production") Boolean production, User user)
throws InternalServerErrorException, NotFoundException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
Survey survey = surveyService.get(surveyId);
if(survey == null) {
throw new NotFoundException(String.format("Survey %s doesn't exist", surveyId));
}
HIT hit = createHITService.createHIT(production, survey);
return new StringResponse(String.format("created HIT with id: %s", hit.getHITId()));
} catch (MturkException e) {
logger.log(Level.SEVERE, "Error creating HIT", e);
throw new InternalServerErrorException(e.getMessage(), e);
}
}
示例5: list
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(
name = "task.list",
path = "task",
httpMethod = HttpMethod.GET
)
public List<Task> list(com.google.appengine.api.users.User gUser, @Nullable @Named("project") String projectId, @Nullable @Named("user") String userId) throws OAuthRequestException, UnauthorizedException, EntityNotFoundException {
userService.ensureEnabled(gUser);
if (projectId != null && userId == null)
return taskService.list(projectId);
else if (projectId == null && userId != null) {
User assignee = userService.get(userId);
if (assignee == null) throw new EntityNotFoundException("User "+userId+" not found");
return taskService.listToDoForUser(assignee);
} else if (projectId == null && userId == null) {
return taskService.list();
} else {
throw new IllegalArgumentException("Please, specify only one of project or user, not both");
}
}
示例6: list
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(
name = "user.list",
path = "user",
httpMethod = HttpMethod.GET
)
public List<User> list(@Named("project") @Nullable String projectId, @Named("q") @Nullable String q, com.google.appengine.api.users.User gUser) throws OAuthRequestException, UnauthorizedException {
userService.ensureEnabled(gUser);
if (projectId != null && q == null) {
Project project = ProjectService.getInstance().get(projectId);
Ref2EntityTransformer<User> t = new Ref2EntityTransformer<User>();
return t.transformTo(project.getUsers());
} else if (projectId == null && q != null) {
return q.equals("") ? UserService.getInstance().list(3) : UserService.getInstance().search(q,3);
} else {
return UserService.getInstance().list();
}
}
示例7: execute0
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(
name = "foos.execute0",
path = "execute0",
httpMethod = "POST"
)
public Object execute0(@Named("id") String id, @Named("i0") int i0,
@Named("i1") @Nullable Integer i1, @Named("long0") long long0,
@Nullable @Named("long1") Long long1, @Named("b0") boolean b0,
@Nullable @Named("b1") Boolean b1, @Named("f") float f,
@Nullable @Named("d") Double d) {
return null;
}
示例8: listQuote
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "listUsers")
public CollectionResponse<Users> listQuote(@Nullable @com.google.api.server.spi.config.Named("cursor") String cursorString,
@Nullable @com.google.api.server.spi.config.Named("count") Integer count) {
Query<Users> query = ofy().load().type(Users.class);
if (count != null) query.limit(count);
if (cursorString != null && cursorString != "") {
query = query.startAt(Cursor.fromWebSafeString(cursorString));
}
List<Users> records = new ArrayList<Users>();
QueryResultIterator<Users> iterator = query.iterator();
int num = 0;
while (iterator.hasNext()) {
records.add(iterator.next());
if (count != null) {
num++;
if (num == count) break;
}
}
//Find the next cursor
if (cursorString != null && cursorString != "") {
Cursor cursor = iterator.getCursor();
if (cursor != null) {
cursorString = cursor.toWebSafeString();
}
}
return CollectionResponse.<Users>builder().setItems(records).setNextPageToken(cursorString).build();
}
示例9: orderlist
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(
name = "orderlist",
httpMethod = ApiMethod.HttpMethod.GET)
public List<Orders> orderlist(@javax.annotation.Nullable @Named("cursor") String cursor){
Query<Orders> query = ofy().load().type(Orders.class).limit(1000);
if (cursor != null)
query = query.startAt(Cursor.fromWebSafeString(cursor));
QueryResultIterator<Orders> queryIterator = query.iterator();
List<Orders> ordersList = new ArrayList<Orders>(1000);
while (queryIterator.hasNext()) {
ordersList.add(queryIterator.next());
}
return ordersList;
}
示例10: getHIT
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "getHIT", path = "getHIT/{id}", httpMethod = HttpMethod.GET)
public HIT getHIT(@Named("id") String id, @Nullable @Named("production") Boolean production,
User user) throws BadRequestException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
return getHITService.getHIT(production, id);
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
示例11: searhHITs
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "searhHITs", path = "searhHITs", httpMethod = HttpMethod.GET)
public List<HIT> searhHITs(@Nullable @Named("production") Boolean production,
User user) throws BadRequestException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
return searchHITsService.searchHITs(production);
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
示例12: disableHIT
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "disableHIT", path = "disableHIT/{id}", httpMethod = HttpMethod.GET)
public StringResponse disableHIT(@Named("id") String id,
@Nullable @Named("production") Boolean production, User user)
throws BadRequestException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
disableHITService.disableHIT(production, id);
return new StringResponse(String.format("HIT %s disabled successfully", id));
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
示例13: disposeHIT
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "disposeHIT", path = "disposeHIT/{id}", httpMethod = HttpMethod.GET)
public StringResponse disposeHIT(@Named("id") String id,
@Nullable @Named("production") Boolean production, User user)
throws BadRequestException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
disposeHITService.disposeHIT(production, id);
return new StringResponse(String.format("HIT %s disposed successfully", id));
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
示例14: getBalance
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "getBalance", path = "getBalance", httpMethod = HttpMethod.GET)
public StringResponse getBalance(@Nullable @Named("production") Boolean production,
User user) throws BadRequestException, UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
return new StringResponse(String.format("Your balance: %.2f", getAccountBalanceService.getBalance(production)));
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
示例15: getAssignmentsForHIT
import com.google.api.server.spi.config.Nullable; //导入依赖的package包/类
@ApiMethod(name = "getAssignmentsForHIT", path = "getAssignmentsForHIT/{hitId}", httpMethod = HttpMethod.GET)
public List<Assignment> getAssignmentsForHIT(@Named("hitId") String hitId,
@Nullable @Named("production") Boolean production, User user) throws BadRequestException,
UnauthorizedException {
Security.verifyAuthenticatedUser(user);
try {
return getAssignmentsForHITService.getAssignments(production, hitId);
} catch (MturkException e) {
throw new BadRequestException(e.getMessage(), e);
}
}