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


Java Validate.isTrue方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.Validate.isTrue方法的典型用法代码示例。如果您正苦于以下问题:Java Validate.isTrue方法的具体用法?Java Validate.isTrue怎么用?Java Validate.isTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.Validate的用法示例。


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

示例1: apply

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void apply( GUIContainer container ) {


        for ( int i = 0; i < rawLayout.length; i++ ) {
            for ( int j = 0; j < rawLayout[i].length(); j++ ) {
                Validate.isTrue( isSet( rawLayout[i].charAt( j ) ), "key: " + rawLayout[i].charAt( j ) + " is not referenced!" );
                GUIElement orig = slots.get( rawLayout[i].charAt( j ) );
                //original element has already be assigned | there should be some bulk change element in the future
                //to receive all affected slots / items
                if(orig.getParent() != null && orig.getPosition() != null){
                    GUIElement clone = (GUIElement) orig.clone();
                    clone.setPosition( new Vector2i( j, i ) );
                    container.add( clone );
                    // clone.draw();
                }else{
                    orig.setPosition(  new Vector2i( j, i )  );
                    container.add( orig );
                }
            }
        }
    }
 
开发者ID:LegendOnline,项目名称:InventoryAPI,代码行数:22,代码来源:ExactLayout.java

示例2: onEndElement

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
public void onEndElement(EBMLElementMetaData elementMetaData, ElementPathSupplier pathSupplier) {
    if(elementMetaData.isMaster()) {
        Validate.isTrue(!currentMkvDataElementInfo.isPresent());
        log.debug("End Master Element to return {}", elementMetaData);
        addMkvElementToReturn(MkvEndMasterElement.builder()
                .elementMetaData(elementMetaData)
                .elementPath(getPath(pathSupplier))
                .build());
    } else {
        if (elementFilter.test(elementMetaData.getTypeInfo())) {
            Validate.isTrue(currentMkvDataElementInfo.isPresent());
            log.debug("Data Element to return {} data size {} ", elementMetaData, readBuffer.position());
            readBuffer.flip();
            addMkvElementToReturn(currentMkvDataElementInfo.get().build(readBuffer));
            currentMkvDataElementInfo = Optional.empty();
        }
    }
}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:20,代码来源:MkvStreamReaderCallback.java

示例3: getEpisodeMap

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
private static ResourceMapParameters getEpisodeMap(String patientIdentifierTypeCode,
                                                   String patientIdentifierAssigningAuthority,
                                                   String patientIdentifierValue,
                                                   String episodeIdentifierTypeCode,
                                                   String episodeIdentifierAssigningAuthority,
                                                   String episodeIdentifierValue) {

    Validate.isTrue(StringUtils.isNotBlank(episodeIdentifierTypeCode) || StringUtils.isNotBlank(episodeIdentifierAssigningAuthority), "episodeIdentifierTypeCode and episodeIdentifierAssigningAuthority are both blank");
    Validate.notBlank(episodeIdentifierValue, "episodeIdentifierValue");

    ResourceMapParameters resourceMapParameters = ResourceMapParameters.create()
            .putExisting(getPatientMap(patientIdentifierTypeCode, patientIdentifierAssigningAuthority, patientIdentifierValue));

    if (StringUtils.isNotEmpty(episodeIdentifierTypeCode))
        resourceMapParameters.put(EpisodeIdentifierTypeCodeKey, episodeIdentifierTypeCode);

    if (StringUtils.isNotEmpty(episodeIdentifierAssigningAuthority))
        resourceMapParameters.put(EpisodeIdentifierAssigningAuthorityKey, episodeIdentifierAssigningAuthority);

    resourceMapParameters.put(EpisodeIdentifierValueKey, episodeIdentifierValue);

    return resourceMapParameters;
}
 
开发者ID:endeavourhealth,项目名称:HL7Receiver,代码行数:24,代码来源:ResourceMapper.java

示例4: nextLong

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * 返回min-max间的随机Long,可传入SecureRandom或ThreadLocalRandom.
 * 
 * min必须大于0.
 * 
 * JDK本身不具有控制两端范围的nextLong,因此参考Commons Lang RandomUtils的实现,
 * 不直接复用是因为要传入Random实例
 *
 * @see org.apache.commons.lang3.RandomUtils#nextLong(long, long)
 */
public static long nextLong(Random random, long min, long max) {
	Validate.isTrue(max >= min, "Start value must be smaller or equal to end value.");
	MoreValidate.nonNegative("min", min);

	if (min == max) {
		return min;
	}

	return (long) (min + ((max - min) * random.nextDouble()));
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:21,代码来源:RandomUtil.java

示例5: init

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@PostConstruct
public void init() throws MalformedURLException {
    Validate.notBlank(scriptDir, "script.directory cannot be empty");
    final File directory = Paths.get(scriptDir).toAbsolutePath().toFile();
    log.info("script.directory is {}", directory.toString());
    Validate.isTrue(directory.isDirectory(), "script.directory must be a directory.");
    Validate.isTrue(directory.canRead(), "script.directory must be readable.");

    runtime = new Runtime(getScriptClassLoader(directory));
}
 
开发者ID:dshell-io,项目名称:dshell,代码行数:11,代码来源:HttpServletScriptController.java

示例6: load

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void load() throws IllegalAccessException {
    for (Field field : MkvTypeInfos.class.getDeclaredFields()) {
        if (Modifier.isStatic(field.getModifiers()) && field.getType().equals(EBMLTypeInfo.class)) {
            EBMLTypeInfo type = (EBMLTypeInfo )field.get(null);
            Validate.isTrue(!typeInfoMap.containsKey(type.getId()));
            typeInfoMap.put(type.getId(), type);
        }
    }
}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:10,代码来源:MkvTypeInfoProvider.java

示例7: findFileByNameInDirectory

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
@Nullable
public File findFileByNameInDirectory(
    @NotNull final File directory,
    @NotNull final String fileName,
    @Nullable final TaskProgressProcessor<File> progressListenerProcessor
) throws InterruptedException {
    Validate.notNull(directory);
    Validate.isTrue(directory.isDirectory());
    Validate.notNull(fileName);

    final Ref<File> result = Ref.create();
    final Ref<Boolean> interrupted = Ref.create(false);

    FileUtil.processFilesRecursively(directory, file -> {
        if (progressListenerProcessor != null && !progressListenerProcessor.shouldContinue(directory)) {
            interrupted.set(true);
            return false;
        }
        if (StringUtils.endsWith(file.getAbsolutePath(), fileName)) {
            result.set(file);
            return false;
        }
        return true;
    });

    if (interrupted.get()) {
        throw new InterruptedException("Modules scanning has been interrupted.");
    }
    return result.get();
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:32,代码来源:DefaultVirtualFileSystemService.java

示例8: readEbmlInt

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * Read an EBML integer value of varying length from the provided buffer.
 * @param byteBuffer The buffer to read from.
 * @return The integer value.
 * @see "http://www.matroska.org/technical/specs/rfc/index.html"
 */
public static long readEbmlInt(final ByteBuffer byteBuffer) {
    final int firstByte =  byteBuffer.get() & BYTE_MASK;
    Validate.isTrue(firstByte >= 0, "EBML Int has negative firstByte" + firstByte);

    final int size = getNumLeadingZeros(firstByte);
    // Read the rest of the bytes
    final long rest = readUnsignedIntegerSevenBytesOrLess(byteBuffer, size);

    // Slap the first byte's value onto the front (with the first one-bit unset)
    return ((firstByte & ~((byte) BYTE_WITH_FIRST_BIT_SET >> size)) << (size * Byte.SIZE) | rest);
}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:18,代码来源:EBMLUtils.java

示例9: writeUTF8String

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * Write a String with UTF8 byte encoding to the buffer.
 * It is encoded as <varint length>[<UTF8 char bytes>]
 * @param to the buffer to write to
 * @param string The string to write
 */
public static void writeUTF8String(ByteBuf to, String string)
{
    byte[] utf8Bytes = string.getBytes(Charsets.UTF_8);
    Validate.isTrue(varIntByteCount(utf8Bytes.length) < 3, "The string is too long for this encoding.");
    writeVarInt(to, utf8Bytes.length, 2);
    to.writeBytes(utf8Bytes);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:ByteBufUtils.java

示例10: onPartialContent

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
public void onPartialContent(EBMLElementMetaData elementMetaData,
        ParserBulkByteSource bulkByteSource,
        int bytesToRead) {
    Validate.isTrue(elementsToReturn.isEmpty());
    if (elementFilter.test(elementMetaData.getTypeInfo())) {
        Validate.isTrue(currentMkvDataElementInfo.isPresent());
        currentMkvDataElementInfo.get().validateExpectedElement(elementMetaData);
        log.debug("Data Element to start buffering data {} bytes to read {} ", elementMetaData, bytesToRead);
    }

    if(!elementMetaData.isMaster()) {
        bulkByteSource.readBytes(readBuffer, bytesToRead);
    }
}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:16,代码来源:MkvStreamReaderCallback.java

示例11: UnLocode

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * @param countryAndLocation Location string.
 */
public UnLocode(String countryAndLocation) {
    Validate.notNull(countryAndLocation,
            "Country and location may not be null");
    Validate.isTrue(VALID_PATTERN.matcher(countryAndLocation).matches(),
            countryAndLocation
            + " is not a valid UN/LOCODE (does not match pattern)");

    this.unlocode = countryAndLocation.toUpperCase();
}
 
开发者ID:RETIT,项目名称:continuous-performance-evaluation,代码行数:13,代码来源:UnLocode.java

示例12: trainTestSplit

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public static IndexSplit trainTestSplit(int length, double testRatio, boolean shuffle, long seed) {
    Validate.isTrue(testRatio > 0.0 && testRatio < 1.0, "testRatio must be in (0, 1) interval");

    int[] indexes = IntStream.range(0, length).toArray();
    if (shuffle) {
        shuffle(indexes, seed);
    }

    int trainSize = (int) (indexes.length * (1 - testRatio));

    int[] trainIndex = Arrays.copyOfRange(indexes, 0, trainSize);
    int[] testIndex = Arrays.copyOfRange(indexes, trainSize, indexes.length);

    return new IndexSplit(trainIndex, testIndex);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-for-Data-Science,代码行数:16,代码来源:CV.java

示例13: getTestInputStream

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public static InputStream getTestInputStream(String name) throws IOException {
    //First check if we are running in maven.
    InputStream inputStream = ClassLoader.getSystemResourceAsStream(name);
    if (inputStream == null) {
        inputStream = newInputStream(Paths.get("testdata", name));
    }
    Validate.isTrue(inputStream != null, "Could not read input file " + name);
    return inputStream;

}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:11,代码来源:TestResourceUtil.java

示例14: setName

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void setName(AdditionalOption option, String name) {
    Validate.isTrue(isPresent(option));
    options.put(option, name);
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:5,代码来源:TSBaseMethodTemplate.java

示例15: readUnsignedInt

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public static long readUnsignedInt(final int in) {
    final long unsignedInt = (long) in - (long) Integer.MIN_VALUE;
    Validate.isTrue(unsignedInt >= 0 && unsignedInt <= MAX_UNSIGNED_INT, "Unsigned int out of range " + unsignedInt);
    return unsignedInt;
}
 
开发者ID:dzikoysk,项目名称:UnknownPandaServer,代码行数:6,代码来源:UnsignedUtils.java


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