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


Java Max类代码示例

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


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

示例1: globalsettingsHolidaysYearPost

import javax.validation.constraints.Max; //导入依赖的package包/类
@Override
@PreAuthorize("hasAuthority('admin')")
public ResponseEntity<Object> globalsettingsHolidaysYearPost( @Min(2000) @Max(2100)@ApiParam(value = "",required=true ) @PathVariable("year") Integer year,
    @ApiParam(value = "The holidays to set" ,required=true )  @Valid @RequestBody Holidays holidays)  throws ApiException {
    try {
         
    globalsettingsService.setHolidays(year, holidays);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    
    } catch (OptimisticLockException ex) {
        try {
            Holidays lastHolidays = globalsettingsService.getHolidays(year);
            throw new ConcurrentModificationException(409, "Concurrent modification error.", lastHolidays);
        } catch (ApiException ex1) {
            Logger.getLogger(SettingsApiController.class.getName()).log(Level.SEVERE, null, ex1);
            throw new ApiException(500, "Concurrent modification exception: internal error");
        }
    }    
    
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:21,代码来源:GlobalsettingsApiController.java

示例2: checkNumberInputType

import javax.validation.constraints.Max; //导入依赖的package包/类
private void checkNumberInputType(Field field) {
	if("number".equals(type)){
		Min min = field.getAnnotation(Min.class);
		if(min != null){
			this.min = min.value();
		}
		Max max = field.getAnnotation(Max.class);
		if(max != null){
			this.max = max.value();
		}
		Range range = field.getAnnotation(Range.class);
		if(range != null){
			this.min = range.min();
			this.max = range.max();
		}
	}
}
 
开发者ID:qlefevre,项目名称:crud-admin-spring-boot-starter,代码行数:18,代码来源:CrudAdminObjectField.java

示例3: addJsr303Annotations

import javax.validation.constraints.Max; //导入依赖的package包/类
private void addJsr303Annotations(final INamedParam parameter,
		final JVar argumentVariable) {
	if (isNotBlank(parameter.getPattern())) {
		JAnnotationUse patternAnnotation = argumentVariable.annotate(Pattern.class);
		patternAnnotation.param("regexp", parameter.getPattern());
	}

	final Integer minLength = parameter.getMinLength();
	final Integer maxLength = parameter.getMaxLength();
	if ((minLength != null) || (maxLength != null)) {
		final JAnnotationUse sizeAnnotation = argumentVariable
				.annotate(Size.class);

		if (minLength != null) {
			sizeAnnotation.param("min", minLength);
		}

		if (maxLength != null) {
			sizeAnnotation.param("max", maxLength);
		}
	}

	final BigDecimal minimum = parameter.getMinimum();
	if (minimum != null) {
		addMinMaxConstraint(parameter, "minimum", Min.class, minimum,
				argumentVariable);
	}

	final BigDecimal maximum = parameter.getMaximum();
	if (maximum != null) {
		addMinMaxConstraint(parameter, "maximum", Max.class, maximum,
				argumentVariable);
	}

	if (parameter.isRequired()) {
		argumentVariable.annotate(NotNull.class);
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:39,代码来源:AbstractGenerator.java

示例4: getFractionIdenticalOfAligned

import javax.validation.constraints.Max; //导入依赖的package包/类
@Min(0)
@Max(1)
public double getFractionIdenticalOfAligned() {
	int nId = 0;
	int nNotIndel = 0;
	for (int i = 1; i <= m_sequencePair.getLength(); i++) {
		String a = m_sequencePair.getCompoundInTargetAt(i).getShortName();
		String b = m_sequencePair.getCompoundInQueryAt(i).getShortName();
		if (!a.equals("-") && !b.equals("-")) {
			nNotIndel++;
			if (a.equals(b)) {
				nId++;
			}
		}
	}
	return (double)nId / nNotIndel;
}
 
开发者ID:dmyersturnbull,项目名称:sequence-alignment,代码行数:18,代码来源:SequenceAlignment.java

示例5: getArchiveByYearMonth

import javax.validation.constraints.Max; //导入依赖的package包/类
@RequestMapping("/{year:[0-9]+}/{month:[0-9]+}/")
public ModelAndView getArchiveByYearMonth(@PathVariable int year,
                                          @Valid @Min(1) @Max(12) @PathVariable int month) {
    LOGGER.debug("Getting the archive, year={}, month={}", year, month);
    // should not be needed in 4.1+
    if (month < 1 || month > 12) {
        return new ModelAndView("error", null);
    }
    ModelMap model = new ModelMap();
    model.addAttribute("posts", documentService.getRecentByYearMonth(year, month, 0, NUM_PER_PAGE));
    model.addAttribute("count", documentService.getCountByYearMonth(year, month));
    model.addAttribute("year", String.valueOf(year));
    model.addAttribute("month", String.format("%02d", month));
    LOGGER.trace("Generated model={}", model);
    return new ModelAndView("archive_year_month", model);
}
 
开发者ID:bkielczewski,项目名称:akanke,代码行数:17,代码来源:BlogController.java

示例6: getRoomByLocation

import javax.validation.constraints.Max; //导入依赖的package包/类
@Override			
@Path("/room")
@GET
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Get room according to indoor location", httpMethod="GET",response=RoomDTO.class)
@ApiResponses(value = {
		@ApiResponse(code = 200, message = "Room belongs to location", response=RoomDTO.class),
		@ApiResponse(code = 400, message = "Invalid input parameter"),
		@ApiResponse(code = 404, message = "Room not found"),
		@ApiResponse(code = 500, message = "Problem in the system")})
public Response getRoomByLocation(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier, 			
		@ApiParam(value="Longitude of location", required=true) @Min(-180) @Max(180) @NotNull @QueryParam("longitude") Double longitude,
		@ApiParam(value="Latitude of location", required=true) @Min(-90) @Max(90) @NotNull @QueryParam("latitude") Double latitude,
		@ApiParam(value = "Floor of location", required = true) @NotNull  @QueryParam("floor") Integer floor) throws AssemblyException, RoomNotFoundException{
	validations.checkIsNotNullAndNotBlank(appIdentifier);
	validations.checkMin(-180.0, longitude);
	validations.checkMax(180.0, longitude);
	validations.checkMin(-90.0, latitude);
	validations.checkMax(90.0, latitude);
	validations.checkIsNotNull(floor);
	
	Feature room=searchManager.getRoomByLocation(appIdentifier, longitude, latitude, floor);			
	RoomDTO roomDTO=roomAssembler.createDataTransferObject(room);				
	return Response.ok(roomDTO).build();		
}
 
开发者ID:osiris-indoor,项目名称:osiris,代码行数:27,代码来源:SearchResourceImpl.java

示例7: testMax

import javax.validation.constraints.Max; //导入依赖的package包/类
@Test
public void testMax() {
	Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, Max.class);
	assertNotNull(violations);
	assertEquals(violations.size(), 1);

	if (runPeformance) {
		long time = System.currentTimeMillis();
		for (int index = 0; index < 10000; index++) {
			validator.validate(obj, Max.class);
		}
		long used = System.currentTimeMillis() - time;
		System.out.println("Hibernate Validator [Max] check used " + used + "ms, avg. " + ((double) used) / 10000
				+ "ms.");
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:17,代码来源:TestObject.java

示例8: compareSequence

import javax.validation.constraints.Max; //导入依赖的package包/类
/**
 * This helper method provides a comparison implementation to order or compare two distinct
 * sequence ids by their internal timestamp <b>and</b> counter value.
 *
 * @param sequenceId1         the first sequence id to be compared
 * @param sequenceId2         the second sequence if to be compared
 * @param maxLogicalNodeCount the maximum node count that was specified at generation time
 * @return a negative integer, zero, or a positive integer as the first argument is less than,
 * equal to, or greater than the second.
 * @throws SnowcastMaxLogicalNodeIdOutOfBoundsException when maxLogicalNodeCount is outside of the legal range
 */
public static int compareSequence(long sequenceId1, long sequenceId2, @Min(128) @Max(8192) int maxLogicalNodeCount) {
    int nodeCount = calculateBoundedMaxLogicalNodeCount(maxLogicalNodeCount);
    int nodeIdShifting = calculateLogicalNodeShifting(nodeCount);
    long counterMask = calculateCounterMask(nodeCount, nodeIdShifting);

    long timestampValue1 = timestampValue(sequenceId1);
    long timestampValue2 = timestampValue(sequenceId2);

    int compare = Long.compare(timestampValue1, timestampValue2);
    if (compare != 0) {
        return compare;
    }

    int counterValue1 = InternalSequencerUtils.counterValue(sequenceId1, counterMask);
    int counterValue2 = InternalSequencerUtils.counterValue(sequenceId2, counterMask);
    return Integer.compare(counterValue1, counterValue2);
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:29,代码来源:SnowcastSequenceUtils.java

示例9: detachLogicalNode

import javax.validation.constraints.Max; //导入依赖的package包/类
void detachLogicalNode(@Nonnull Address address, @Min(128) @Max(8192) int logicalNodeId) {
    while (true) {
        Object[] assignmentTable = this.assignmentTable;
        Address addressOnSlot = (Address) assignmentTable[logicalNodeId];
        if (addressOnSlot == null) {
            break;
        }

        if (!address.equals(addressOnSlot)) {
            throw exception(SnowcastIllegalStateException::new, ILLEGAL_DETACH_ATTEMPT);
        }

        long offset = offset(logicalNodeId);
        if (UNSAFE.compareAndSwapObject(assignmentTable, offset, addressOnSlot, null)) {
            break;
        }
    }
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:19,代码来源:LogicalNodeTable.java

示例10: createSequencer

import javax.validation.constraints.Max; //导入依赖的package包/类
@Nonnull
@Override
public SnowcastSequencer createSequencer(@Nonnull String sequencerName, @Nonnull SnowcastEpoch epoch,
                                         @Min(128) @Max(8192) int maxLogicalNodeCount,
                                         @Nonnegative @Max(Short.MAX_VALUE) short backupCount) {

    TRACER.trace("register sequencer %s with epoch %s, max nodes %s, backups %s", //
            sequencerName, epoch, maxLogicalNodeCount, backupCount);

    SequencerDefinition definition = new SequencerDefinition(sequencerName, epoch, maxLogicalNodeCount, backupCount);

    try {
        SequencerDefinition realDefinition = clientCodec.createSequencerDefinition(sequencerName, definition);
        return getOrCreateSequencerProvision(realDefinition).getSequencer();
    } finally {
        TRACER.trace("register sequencer %s end", sequencerName);
    }
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:19,代码来源:ClientSequencerService.java

示例11: SequencerDefinition

import javax.validation.constraints.Max; //导入依赖的package包/类
public SequencerDefinition(@Nonnull String sequencerName, @Nonnull SnowcastEpoch epoch,
                           @Min(128) @Max(8192) int maxLogicalNodeCount,
                           @Nonnegative @Max(Short.MAX_VALUE) short backupCount) {

    if (maxLogicalNodeCount < NODE_ID_LOWER_BOUND) {
        throw exception(SnowcastMaxLogicalNodeIdOutOfBoundsException::new, //
                ILLEGAL_MAX_LOGICAL_NODE_ID_BOUNDARY, "smaller", NODE_ID_LOWER_BOUND);
    }
    if (maxLogicalNodeCount > NODE_ID_UPPER_BOUND) {
        throw exception(SnowcastMaxLogicalNodeIdOutOfBoundsException::new, //
                ILLEGAL_MAX_LOGICAL_NODE_ID_BOUNDARY, "larger", NODE_ID_UPPER_BOUND);
    }

    this.sequencerName = sequencerName;
    this.epoch = epoch;
    this.maxLogicalNodeCount = maxLogicalNodeCount;
    this.backupCount = backupCount;
    this.boundedMaxLogicalNodeCount = InternalSequencerUtils.calculateBoundedMaxLogicalNodeCount(maxLogicalNodeCount);
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:20,代码来源:SequencerDefinition.java

示例12: calculateLogicalNodeShifting

import javax.validation.constraints.Max; //导入依赖的package包/类
@Nonnegative
public static int calculateLogicalNodeShifting(@Min(128) @Max(8192) int maxLogicalNodeCount) {
    switch (maxLogicalNodeCount) {
        case MAX_LOGICAL_NODE_COUNT_128:
            return SHIFT_LOGICAL_NODE_ID_128;
        case MAX_LOGICAL_NODE_COUNT_256:
            return SHIFT_LOGICAL_NODE_ID_256;
        case MAX_LOGICAL_NODE_COUNT_512:
            return SHIFT_LOGICAL_NODE_ID_512;
        case MAX_LOGICAL_NODE_COUNT_1024:
            return SHIFT_LOGICAL_NODE_ID_1024;
        case MAX_LOGICAL_NODE_COUNT_2048:
            return SHIFT_LOGICAL_NODE_ID_2048;
        case MAX_LOGICAL_NODE_COUNT_4096:
            return SHIFT_LOGICAL_NODE_ID_4096;
        case MAX_LOGICAL_NODE_COUNT_8192:
            return SHIFT_LOGICAL_NODE_ID_8192;
        default:
            throw exception(IllegalArgumentException::new, ILLEGAL_MAX_LOGICAL_NODE_COUNT);
    }
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:22,代码来源:InternalSequencerUtils.java

示例13: createSequencer

import javax.validation.constraints.Max; //导入依赖的package包/类
@Nonnull
@Override
public SnowcastSequencer createSequencer(@Nonnull String sequencerName, @Nonnull SnowcastEpoch epoch,
                                         @Min(128) @Max(8192) int maxLogicalNodeCount, short backupCount) {

    SequencerDefinition definition = new SequencerDefinition(sequencerName, epoch, maxLogicalNodeCount, backupCount);

    Operation operation = new CreateSequencerDefinitionOperation(definition);
    SequencerDefinition realDefinition = invoke(operation, sequencerName);

    if (!definition.equals(realDefinition)) {
        throw exception(SnowcastIllegalStateException::new, SEQUENCER_ALREADY_REGISTERED);
    }

    return getOrCreateSequencerProvision(realDefinition).getSequencer();
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:17,代码来源:NodeSequencerService.java

示例14: fromAnnotation

import javax.validation.constraints.Max; //导入依赖的package包/类
/**
 * Builds a new constraint from the annotation data.
 * @param anno JSR-303 annotation instance
 * @return a new constraint
 */
public static Constraint fromAnnotation(Annotation anno) {
	if (anno instanceof Min) {
		return min(((Min) anno).value());
	} else if (anno instanceof Max) {
		return max(((Max) anno).value());
	} else if (anno instanceof Size) {
		return size(((Size) anno).min(), ((Size) anno).max());
	} else if (anno instanceof Digits) {
		return digits(((Digits) anno).integer(), ((Digits) anno).fraction());
	} else if (anno instanceof Pattern) {
		return pattern(((Pattern) anno).regexp());
	} else {
		return new Constraint(VALIDATORS.get(anno.annotationType()),
				simplePayload(VALIDATORS.get(anno.annotationType()))) {
					public boolean isValid(Object actualValue) {
						return true;
					}
				};
	}
}
 
开发者ID:Erudika,项目名称:para,代码行数:26,代码来源:Constraint.java

示例15: getType

import javax.validation.constraints.Max; //导入依赖的package包/类
@Override
protected String getType()  {
    String type = javaToHtmlTypes.get(valueType);
    if (type != null) {
        return type;
    }
    type = "text";
    if (annotations != null) {
        if (annotations.containsKey(Email.class)) {
            type = "email";
        } else if (annotations.containsKey(URL.class)) {
            type = "url";
        } else if (annotations.containsKey(Max.class) || annotations.containsKey(Min.class)) {
            type = "number";
        }
    }
    return type;
}
 
开发者ID:arey,项目名称:spring-mvc-toolkit,代码行数:19,代码来源:Html5InputTag.java


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