类javax.validation.constraints.PositiveOrZero源码实例Demo

下面列出了怎么用javax.validation.constraints.PositiveOrZero的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Determine a number type's minimum (inclusive) value.
 *
 * @param member the field or method to check
 * @return specified inclusive minimum value (or null)
 * @see Min
 * @see DecimalMin
 * @see PositiveOrZero
 */
protected BigDecimal resolveNumberInclusiveMinimum(MemberScope<?, ?> member) {
    Min minAnnotation = this.getAnnotationFromFieldOrGetter(member, Min.class, Min::groups);
    if (minAnnotation != null) {
        return new BigDecimal(minAnnotation.value());
    }
    DecimalMin decimalMinAnnotation = this.getAnnotationFromFieldOrGetter(member, DecimalMin.class, DecimalMin::groups);
    if (decimalMinAnnotation != null && decimalMinAnnotation.inclusive()) {
        return new BigDecimal(decimalMinAnnotation.value());
    }
    PositiveOrZero positiveAnnotation = this.getAnnotationFromFieldOrGetter(member, PositiveOrZero.class, PositiveOrZero::groups);
    if (positiveAnnotation != null) {
        return BigDecimal.ZERO;
    }
    return null;
}
 
源代码2 项目: microshed-testing   文件: PersonServiceWithJDBC.java
@POST
  public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                           @QueryParam("age") @PositiveOrZero int age){
Person p = new Person(name, age);

try (Connection conn = defaultDataSource.getConnection();
	 PreparedStatement ps = conn.prepareStatement("INSERT INTO people VALUES(?,?,?)")){
	ps.setLong(1, p.id);
	ps.setString(2, name);
	ps.setInt(3, age);
	ps.execute();		
	return p.id;	
} catch (SQLException e) {
	e.printStackTrace(System.out);
}
throw new InternalServerErrorException("Could not create new person");    
  }
 
@POST
  public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                           @QueryParam("age") @PositiveOrZero int age){
Person p = new Person(name, age);

try (Connection conn = defaultDataSource.getConnection();
	 PreparedStatement ps = conn.prepareStatement("INSERT INTO people VALUES(?,?,?)")){
	ps.setLong(1, p.id);
	ps.setString(2, name);
	ps.setInt(3, age);
	ps.execute();		
	return p.id;	
} catch (SQLException e) {
	e.printStackTrace(System.out);
}
throw new InternalServerErrorException("Could not create new person");    
  }
 
源代码4 项目: RestDoc   文件: PositiveOrZeroPostProcessor.java
@Override
public PropertyModel postProcessInternal(PropertyModel propertyModel) {
    PositiveOrZero positiveOrZeroAnno = propertyModel.getPropertyItem().getAnnotation(PositiveOrZero.class);
    if (positiveOrZeroAnno == null)  return propertyModel;

    propertyModel.setDescription(TextUtils.combine(
            propertyModel.getDescription(),
            " (值只能为正数,包括0)"
    ));
    return propertyModel;
}
 
源代码5 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码6 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码7 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码8 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    peopleCollection.insertOne(p.toDocument());
    return p.id;
}
 
源代码10 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码11 项目: microshed-testing   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码12 项目: egeria   文件: AnalyticsModelingOMASResource.java
/**
 * Get list of databases.
    * @param serverName	unique identifier for requested server.
    * @param userId		the unique identifier for the user
    * @param startFrom		starting element (used in paging through large result sets)
    * @param pageSize		maximum number of results to return
 * @return Analytics Modeling response contains list of databases.
 */
@GetMapping(path = "/databases")
public AnalyticsModelingOMASAPIResponse getDatabases(
		@PathVariable("serverName") String serverName,
           @PathVariable("userId") String userId,
           @PositiveOrZero(message = "startFrom should be a positive number")
           @RequestParam Integer startFrom,
           @PositiveOrZero(message = "pageSize should be a positive number")
           @RequestParam Integer pageSize
           )
{
	return restAPI.getDatabases(serverName, userId, startFrom, pageSize);
}
 
源代码13 项目: egeria   文件: AnalyticsModelingOMASResource.java
/**
 * Get list of schemas of a given dataSource.
    * @param serverName	unique identifier for requested server.
    * @param userId		the unique identifier for the user
 * @param dataSource	data source GUID.
    * @param startFrom		starting element (used in paging through large result sets)
    * @param pageSize		maximum number of results to return
 * @return Analytics Modeling response contains list of database schemas.
 */
@GetMapping(path = "/{dataSourceGUID}/schemas")
public AnalyticsModelingOMASAPIResponse getSchemas(
		@PathVariable("serverName") String serverName,
           @PathVariable("userId") String userId,
           @PathVariable("dataSourceGUID") String dataSource,
           @PositiveOrZero(message = "startFrom should be a positive number")
           @RequestParam Integer startFrom,
           @PositiveOrZero(message = "pageSize should be a positive number")
           @RequestParam Integer pageSize
		)
{
	return restAPI.getSchemas(serverName, userId, dataSource, startFrom, pageSize);
}
 
源代码14 项目: egeria   文件: InformationViewOMASResource.java
/**
 * Returns the list of databases
 *
 * @param serverName  unique identifier for requested server.
 * @param userId      the unique identifier for the user
 * @param startFrom starting element (used in paging through large result sets)
 * @param pageSize maximum number of results to return
 * @return list of databases
 */
@GetMapping(path = "/databases")
public InformationViewOMASAPIResponse retrieveDatabases(@PathVariable("serverName") String serverName,
                                                        @PathVariable("userId") String userId,
                                                        @PositiveOrZero(message = "startFrom should be a positive number")
                                                        @RequestParam Integer startFrom,
                                                        @PositiveOrZero(message = "pageSize should be a positive number")
                                                        @RequestParam Integer pageSize) {
    return restAPI.getDatabases(serverName, userId, startFrom, pageSize);
}
 
源代码15 项目: egeria   文件: InformationViewOMASResource.java
/**
 *
 * Retrieve list of tables for a database
 *
 * @param serverName  unique identifier for requested server.
 * @param userId      the unique identifier for the user
 * @param databaseGuid guid of database for which we want to retrieve the list of tables
 * @param startFrom starting element (used in paging through large result sets)
 * @param pageSize maximum number of results to return
 * @return list of tables belonging to the database
 */
@GetMapping(path = "databases/{database}/tables")
public InformationViewOMASAPIResponse retrieveTablesForDatabase(@PathVariable("serverName") String serverName,
                                                                @PathVariable("userId") String userId,
                                                                @NotBlank(message = "guid of the database should not be blank")
                                                                @PathVariable("database") String databaseGuid,
                                                                @PositiveOrZero(message = "startFrom should be a positive number")
                                                                @RequestParam int startFrom,
                                                                @PositiveOrZero(message = "pageSize should be a positive number")
                                                                @RequestParam int pageSize) {
    return restAPI.getTablesForDatabase(serverName, userId, databaseGuid, startFrom, pageSize);
}
 
源代码16 项目: egeria   文件: InformationViewOMASResource.java
/**
 * Retrieve list of columns for a table using pagination
 *
 * @param serverName  unique identifier for requested server.
 * @param userId      the unique identifier for the user
 * @param tableGuid guid of the table
 * @param startFrom starting element (used in paging through large result sets)
 * @param pageSize maximum number of results to return
 * @return list of columns belonging to the table
 */
@GetMapping(path = "tables/{table}/columns")
public InformationViewOMASAPIResponse retrieveTableColumns(@PathVariable("serverName") String serverName,
                                                           @PathVariable("userId") String userId,
                                                           @NotBlank(message = "guid of the table should not be blank")
                                                           @PathVariable("table") String tableGuid,
                                                           @PositiveOrZero(message = "startFrom should be a positive number")
                                                           @RequestParam Integer startFrom,
                                                           @PositiveOrZero(message = "pageSize should be a positive number")
                                                           @RequestParam Integer pageSize) {
    return restAPI.getTableColumns(serverName, userId, tableGuid, startFrom, pageSize);
}
 
源代码17 项目: microprofile-sandbox   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码18 项目: microprofile-sandbox   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    peopleCollection.insertOne(p.toDocument());
    return p.id;
}
 
源代码20 项目: microprofile-sandbox   文件: PersonService.java
@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50) String name,
                         @QueryParam("age") @PositiveOrZero int age) {
    Person p = new Person(name, age);
    personRepo.put(p.id, p);
    return p.id;
}
 
源代码21 项目: apollo   文件: CommitController.java
@GetMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits")
public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env,
                            @PathVariable String clusterName, @PathVariable String namespaceName,
                            @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page,
                            @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "10") int size) {
  if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) {
    return Collections.emptyList();
  }

  return commitService.find(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
}
 
源代码22 项目: apollo   文件: ReleaseController.java
@GetMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all")
public List<ReleaseBO> findAllReleases(@PathVariable String appId,
                                       @PathVariable String env,
                                       @PathVariable String clusterName,
                                       @PathVariable String namespaceName,
                                       @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page,
                                       @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "5") int size) {
  if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) {
    return Collections.emptyList();
  }

  return releaseService.findAllReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
}
 
源代码23 项目: apollo   文件: ReleaseController.java
@GetMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active")
public List<ReleaseDTO> findActiveReleases(@PathVariable String appId,
                                           @PathVariable String env,
                                           @PathVariable String clusterName,
                                           @PathVariable String namespaceName,
                                           @Valid @PositiveOrZero(message = "page should be positive or 0") @RequestParam(defaultValue = "0") int page,
                                           @Valid @Positive(message = "size should be positive number") @RequestParam(defaultValue = "5") int size) {

  if (permissionValidator.shouldHideConfigToCurrentUser(appId, env, namespaceName)) {
    return Collections.emptyList();
  }

  return releaseService.findActiveReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
}
 
@PositiveOrZero(groups = Test.class)
public BigInteger getPositiveOrZeroOnGetterBigInteger() {
    return positiveOrZeroOnGetterBigInteger;
}
 
源代码25 项目: springdoc-openapi   文件: HelloController.java
@GetMapping(value = "/persons4")
public String persons4(@PositiveOrZero int age) {
	return "OK";
}
 
源代码26 项目: BlogManagePlatform   文件: DefaultModelPlugin.java
private String resolveRange(Field field) {
	String min = Optional.ofNullable(field.getAnnotation(Min.class)).map((item) -> String.valueOf(item.value())).orElse(null);
	if (min == null) {
		min = Optional.ofNullable(field.getAnnotation(DecimalMin.class)).map(DecimalMin::value).orElse(null);
	}
	if (field.isAnnotationPresent(PositiveOrZero.class)) {
		if (min == null || new BigDecimal(min).compareTo(BigDecimal.ZERO) < 0) {
			min = "非负数";
		}
	}
	if (field.isAnnotationPresent(Positive.class)) {
		if (min == null || new BigDecimal(min).compareTo(BigDecimal.ZERO) <= 0) {
			min = "正数";
		}
	}
	min = min == null ? null : StrUtil.concat("最小值为", min);
	if (field.isAnnotationPresent(DecimalMin.class)) {
		if (!field.getAnnotation(DecimalMin.class).inclusive()) {
			min = min == null ? null : StrUtil.concat(min, "且不能等于最小值");
		}
	}
	String max = Optional.ofNullable(field.getAnnotation(Max.class)).map((item) -> String.valueOf(item.value())).orElse(null);
	if (max == null) {
		max = Optional.ofNullable(field.getAnnotation(DecimalMax.class)).map(DecimalMax::value).orElse(null);
	}
	if (field.isAnnotationPresent(NegativeOrZero.class)) {
		if (max == null || new BigDecimal(max).compareTo(BigDecimal.ZERO) > 0) {
			max = "非正数";
		}
	}
	if (field.isAnnotationPresent(Negative.class)) {
		if (max == null || new BigDecimal(min).compareTo(BigDecimal.ZERO) >= 0) {
			max = "负数";
		}
	}
	max = max == null ? null : StrUtil.concat("最大值为", max);
	if (field.isAnnotationPresent(DecimalMax.class)) {
		if (!field.getAnnotation(DecimalMax.class).inclusive()) {
			min = min == null ? null : StrUtil.concat(min, "且不能等于最大值");
		}
	}
	String digit = Optional.ofNullable(field.getAnnotation(Digits.class)).map((item) -> {
		String integer = String.valueOf(item.integer());
		String fraction = String.valueOf(item.fraction());
		return StrUtil.concat("整数位", integer, ",", "小数位", fraction);
	}).orElse(null);
	if (min == null && max == null && digit == null) {
		return null;
	}
	return StrUtil.join(",", min, max, digit);
}
 
源代码27 项目: centraldogma   文件: CentralDogmaSettings.java
/**
 * Sets the number of milliseconds between each health-check requests to Central Dogma servers.
 */
public void setHealthCheckIntervalMillis(@PositiveOrZero long healthCheckIntervalMillis) {
    this.healthCheckIntervalMillis = healthCheckIntervalMillis;
}
 
源代码28 项目: egeria   文件: TermResource.java
/**
 * Extract all terms definitions
 *
 * @param serverName instance to call
 * @param userId calling user
 * @param from from
 * @param size size
 *
 * @return all terms
 */
@GetMapping( path = "/terms")
public GlossaryViewEntityDetailResponse getAllTerms(@PathVariable("serverName") String serverName,
                                                         @PathVariable("userId") String userId,
                                                         @RequestParam(name="from", defaultValue=PAGE_FROM_DEFAULT_VALUE) @PositiveOrZero Integer from,
                                                         @RequestParam(name="size", defaultValue=PAGE_SIZE_DEFAULT_VALUE) @PositiveOrZero @Max(PAGE_SIZE_MAX_VALUE) Integer size) {
    return termService.getAllTerms(userId, serverName, from, size);
}
 
源代码29 项目: egeria   文件: TermResource.java
/**
 * Extract term definitions for the given glossary GUID via the 'TermAnchor' type relationships
 *
 * @param serverName instance to call
 * @param userId calling user
 * @param glossaryGUID glossary GUID
 * @param from from
 * @param size size
 *
 * @return terms
 */
@GetMapping( path = "/glossaries/{glossaryGUID}/terms")
public GlossaryViewEntityDetailResponse getTermsViaTermAnchorRelationships(@PathVariable("serverName") String serverName,
                                                                           @PathVariable("userId") String userId,
                                                                           @PathVariable("glossaryGUID") @NotBlank String glossaryGUID,
                                                                           @RequestParam(name="from", defaultValue=PAGE_FROM_DEFAULT_VALUE) @PositiveOrZero Integer from,
                                                                           @RequestParam(name="size", defaultValue=PAGE_SIZE_DEFAULT_VALUE) @PositiveOrZero @Max(PAGE_SIZE_MAX_VALUE) Integer size) {
    return termService.getTermsViaTermAnchorRelationships(userId, serverName, glossaryGUID, from, size);
}
 
源代码30 项目: egeria   文件: TermResource.java
/**
 * Extract term definitions for the given GUID via the 'TermCategorization' type relationships
 *
 * @param serverName instance to call
 * @param userId calling user
 * @param categoryGUID category GUID
 * @param from from
 * @param size size
 *
 * @return subcategories
 */
@GetMapping( path = "/categories/{categoryGUID}/terms")
public GlossaryViewEntityDetailResponse getTermsViaTermCategorizationRelationships(@PathVariable("serverName") String serverName,
                                                                                   @PathVariable("userId") String userId,
                                                                                   @PathVariable("categoryGUID") @NotBlank String categoryGUID,
                                                                                   @RequestParam(name="from", defaultValue=PAGE_FROM_DEFAULT_VALUE) @PositiveOrZero Integer from,
                                                                                   @RequestParam(name="size", defaultValue=PAGE_SIZE_DEFAULT_VALUE) @PositiveOrZero @Max(PAGE_SIZE_MAX_VALUE) Integer size) {
    return termService.getTermsViaTermCategorizationRelationships(userId, serverName, categoryGUID, from, size);
}