当前位置: 首页>>代码示例>>Java>>正文


Java NotNull类代码示例

本文整理汇总了Java中javax.validation.constraints.NotNull的典型用法代码示例。如果您正苦于以下问题:Java NotNull类的具体用法?Java NotNull怎么用?Java NotNull使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NotNull类属于javax.validation.constraints包,在下文中一共展示了NotNull类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRemoteIp

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * Pulls the remote IP from the current HttpServletRequest, or grabs the value
 * for the specified alternative attribute (say, for proxied requests).  Falls
 * back to providing the "normal" remote address if no value can be retrieved
 * from the specified alternative header value.
 * @param context the context
 * @return the remote ip
 */
private String getRemoteIp(@NotNull final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    String userAddress = request.getRemoteAddr();
    logger.debug("Remote Address = {}", userAddress);

    if (StringUtils.isNotBlank(this.alternativeRemoteHostAttribute)) {

        userAddress = request.getHeader(this.alternativeRemoteHostAttribute);
        logger.debug("Header Attribute [{}] = [{}]", this.alternativeRemoteHostAttribute, userAddress);

        if (StringUtils.isBlank(userAddress)) {
            userAddress = request.getRemoteAddr();
            logger.warn("No value could be retrieved from the header [{}]. Falling back to [{}].",
                    this.alternativeRemoteHostAttribute, userAddress);
        }
    }
    return userAddress;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:BaseSpnegoKnownClientSystemsFilterAction.java

示例2: fetchJobStderrById

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@GET
@Path("/{job-id}/stderr")
@ApiOperation(
        value = "Get the job's standard error",
        notes = "Get the job's standard error, if available. A job that has not yet starrted will not have a standard error and, " +
                "therefore, this method will return a 404. There is no guarantee that all running/finished jobs will have standard " +
                "error data. This is because administrative and cleanup routines may dequeue a job's output in order to save space on " +
                "the server.")
@Produces(DEFAULT_BINARY_MIME_TYPE)
@PermitAll
public Response fetchJobStderrById(
        @Context
                SecurityContext context,
        @ApiParam(value = "ID of the job to get stderr for")
        @PathParam("job-id")
        @NotNull
        JobId jobId) {

    if (jobId == null)
        throw new WebApplicationException("Job ID cannot be null", 400);

    return generateBinaryDataResponse(jobId, jobDAO.getStderr(jobId));
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:24,代码来源:JobResource.java

示例3: createCell

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET, path = "/createCell")
public void createCell(@NotNull @RequestParam String name, @NotNull @RequestParam CellType cellType) throws ExecutionException, InterruptedException {
    JSONObject cell = new JSONObject();
    cell.put("name", name);
    cell.put("type", cellType);

    ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(topic, cell.toString());
    future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
        @Override
        public void onSuccess(SendResult<String, String> result) {
            System.out.println("success");
        }

        @Override
        public void onFailure(Throwable ex) {
            System.out.println("failed");
        }
    });
}
 
开发者ID:Chabane,项目名称:mitosis-microservice-spring-reactor,代码行数:20,代码来源:SpringBootKafkaController.java

示例4: getFactById

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@GET
@Path("/uuid/{id}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Retrieve a Fact by its UUID.",
        notes = "This operation returns a Fact identified by its UUID. The result includes the Objects directly " +
                "linked to the requested Fact. The request will be rejected with a 403 if a user does not have " +
                "access to the requested Fact.\n\n" +
                "If the accessMode is 'Public' the Fact will be available to everyone. If the accessMode is " +
                "'Explicit' only users in the Fact's ACL will have access to the Fact. If the accessMode is " +
                "'RoleBased' (the default mode) a user must be either in the Fact's ACL or have general role-based " +
                "access to the Organization owning the Fact. A user who created a Fact will always have access to it.",
        response = Fact.class
)
@ApiResponses({
        @ApiResponse(code = 401, message = "User could not be authenticated."),
        @ApiResponse(code = 403, message = "User is not allowed to perform this operation."),
        @ApiResponse(code = 404, message = "Requested Fact does not exist."),
        @ApiResponse(code = 412, message = "Any parameter has an invalid format.")
})
public Response getFactById(
        @PathParam("id") @ApiParam(value = "UUID of the requested Fact.") @NotNull @Valid UUID id
) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException, ObjectNotFoundException {
  return buildResponse(service.getFact(getHeader(), new GetFactByIdRequest().setId(id)));
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:26,代码来源:FactEndpoint.java

示例5: updateReview

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void updateReview(
        @NotNull @Valid final Review review,
        @Min(1) final Long reviewId,
        @NotNull final MovieEntity movie
) throws ResourceConflictException {
    log.info("Called with review {}, reviewId {}, movie {}", review, reviewId, movie);

    this.existsReview(movie.getReviews()
            .stream()
            .filter(r -> r.getStatus() == DataStatus.ACCEPTED)
            .collect(Collectors.toList()), review);

    final MovieReviewEntity movieReview = this.entityManager.find(MovieReviewEntity.class, reviewId);
    movieReview.setTitle(review.getTitle());
    movieReview.setReview(review.getReview());
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:21,代码来源:MoviePersistenceServiceImpl.java

示例6: jsr349SimpleInvalid

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@Test
public void jsr349SimpleInvalid() {
	try {
		validationInInterceptor.handleValidation(MESSAGE, INSTANCE, fromName("jsr349Simple"), Arrays.asList(new Object[] { null }));
		Assert.fail("Expected validation errors");
	} catch (final ConstraintViolationException cve) {

		// Check all expected errors are there.
		final Set<ConstraintViolation<?>> constraintViolations = cve.getConstraintViolations();
		Assert.assertNotNull(constraintViolations);
		Assert.assertEquals(1, constraintViolations.size());

		// Check expected errors
		final ConstraintViolation<?> error1 = constraintViolations.iterator().next();
		Assert.assertEquals(NotNull.class, error1.getConstraintDescriptor().getAnnotation().annotationType());
		Assert.assertEquals("jsr349Simple.param", error1.getPropertyPath().toString());
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:19,代码来源:JAXRSBeanValidationImplicitInInterceptorTest.java

示例7: execute

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@NotNull
@Override
public ProvisionServiceInstanceCommand.Response execute(@NotNull final ProvisionServiceInstanceCommand command) throws ServiceBrokerException {
  Objects.requireNonNull(command, () -> "command must not be null");
  ProvisionServiceInstanceCommand.Response returnValue = null;
  final String serviceId = command.getServiceId();
  if (serviceId != null) {
    ServiceBroker serviceBroker = null;
    try {
      this.serviceBrokerAssociationLock.readLock().lock();
      serviceBroker = this.getServiceBrokerForServiceId(serviceId);
    } finally {
      this.serviceBrokerAssociationLock.readLock().unlock();
    }
    if (serviceBroker != null) {
      returnValue = serviceBroker.execute(command);
    }
  }
  if (returnValue == null) {
    throw new InvalidServiceBrokerCommandException(command);
  }
  return returnValue;
}
 
开发者ID:microbean,项目名称:microbean-service-broker-api,代码行数:24,代码来源:CompositeServiceBroker.java

示例8: MovieSearchResult

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param id The movie ID
 * @param title The title of the movie
 * @param type The type of the movie
 * @param rating The movie rating
 */
@JsonCreator
public MovieSearchResult(
        @NotNull @JsonProperty("id") final Long id,
        @NotBlank @JsonProperty("title") final String title,
        @NotNull @JsonProperty("type") final MovieType type,
        @NotNull @JsonProperty("rating") final Float rating
) {
    super(id.toString());
    this.title = title;
    this.type = type;
    this.rating = rating;
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:21,代码来源:MovieSearchResult.java

示例9: ServiceContext

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * Creates a new instance with required parameters.
 *
 * @param service Service principal.
 * @param registeredService Registered service corresponding to given service.
 */
public ServiceContext(@NotNull final Service service, @NotNull final RegisteredService registeredService) {
    this.service = service;
    this.registeredService = registeredService;
    if (!registeredService.matches(service)) {
        throw new IllegalArgumentException("Registered service does not match given service.");
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:14,代码来源:ServiceContext.java

示例10: getMultiValuedAttributeValues

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * Gets the attribute values if more than one, otherwise an empty list.
 *
 * @param entry the entry
 * @param attrName the attr name
 * @return the collection of attribute values
 */
private Collection<String> getMultiValuedAttributeValues(@NotNull final LdapEntry entry, @NotNull final String attrName) {
    final LdapAttribute attrs = entry.getAttribute(attrName);
    if (attrs != null) {
        return attrs.getStringValues();
    }
    return Collections.emptyList();
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:15,代码来源:DefaultLdapRegisteredServiceMapper.java

示例11: questionGetGet

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@ApiOperation(value = "问题获取", notes = "问题获取", response = ResultDTO.class, tags = { "ZhihuQuestion", })
@ApiResponses(value = { @ApiResponse(code = 200, message = "返回问题对象", response = ResultDTO.class),
		@ApiResponse(code = 200, message = "返回错误信息", response = ResultDTO.class) })

@RequestMapping(value = "/question/get", produces = { "application/json" }, method = RequestMethod.GET)
ResponseEntity<ResultDTO> questionGetGet(
		@NotNull @ApiParam(value = "问题id", required = true, defaultValue = "0213f784cdd9493aab7d44683b0bbb1d") @RequestParam(value = "id", required = true) String id);
 
开发者ID:sdc1234,项目名称:zhihu-spider,代码行数:8,代码来源:QuestionApi.java

示例12: DseGraphHealthCheck

import javax.validation.constraints.NotNull; //导入依赖的package包/类
public DseGraphHealthCheck(
        @NotNull DseSession session,
        @NotNull String validationQuery,
        @NotNull Duration validationTimeout) {

    this.session = session;
    this.validationQuery = validationQuery;
    this.validationTimeout = validationTimeout;
}
 
开发者ID:experoinc,项目名称:dropwizard-dsegraph,代码行数:10,代码来源:DseGraphHealthCheck.java

示例13: getLogstashPort

import javax.validation.constraints.NotNull; //导入依赖的package包/类
/**
 * Get logstashPort
 * @return logstashPort
 **/
@JsonProperty("logstash_port")
@ApiModelProperty(example = "5044", required = true, value = "")
@NotNull
public String getLogstashPort() {
  return logstashPort;
}
 
开发者ID:elastest,项目名称:elastest-instrumentation-manager,代码行数:11,代码来源:AgentFull.java

示例14: onMessage

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@Override
public void onMessage(@NotNull final Message msg, @NotNull final ActorLifecycleMessage lifecycleMessage) {
    requireNonNull(msg);
    requireNonNull(lifecycleMessage);

    lifecycleMessage.sendTo(actorsListener);
}
 
开发者ID:florentw,项目名称:bench,代码行数:8,代码来源:JgroupsActorRegistryClusterClient.java

示例15: parseProperty

import javax.validation.constraints.NotNull; //导入依赖的package包/类
@Override
void parseProperty(@NotNull ArrayGenerator generator, @NotNull JsonArrayProperty property, @NotNull JsonNode node) {
    switch (property) {
        case ITEMS:
            if (node.isArray()) {
                Iterator<JsonNode> nodeIterator = node.elements();
                while (nodeIterator.hasNext()) {
                    addItem(generator, nodeIterator.next());
                }
            } else {
                addItem(generator, node);
            }
            break;
        case ADDITIONAL_ITEMS:
            generator.setAdditionalItems(node.booleanValue());
            break;
        case MAX_ITEMS:
            generator.setMaxItems(node.intValue());
            break;
        case MIN_ITEMS:
            generator.setMinItems(node.intValue());
            break;
        case UNIQUE_ITEMS:
            generator.setUniqueItems(node.booleanValue());
            break;
    }
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:28,代码来源:ArrayParser.java


注:本文中的javax.validation.constraints.NotNull类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。