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


Java Validate.isTrue方法代码示例

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


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

示例1: getChangedSkin

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
/**
 * Gets a player's changed skin
 *
 * @param player the player to get the changed skin of
 * @return the changed skin
 */
public Skin getChangedSkin(Player player) {
    Validate.isTrue(enabled, "NameTagChanger is disabled");
    GameProfileWrapper profile = gameProfiles.get(player.getUniqueId());
    if (profile == null) {
        return null;
    }
    Skin skin = getSkinFromGameProfile(profile);
    if (skin.equals(getDefaultSkinFromPlayer(player))) {
        // The skin is the normal skin for the player,
        // meaning there is no changed skin
        return null;
    } else {
        return skin;
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:22,代码来源:NameTagChanger.java

示例2: playEffect

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
    if (data != null) {
        Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
    } else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
    }

    if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) {
        org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data;
        Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" );
        spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius );
    } else {
        int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data );
        playEffect( loc, effect, dataValue, radius );
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftWorld.java

示例3: loadAddons

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
@Override
public Addon[] loadAddons(File directory) {
    Validate.notNull(directory, "Directory cannot be null");
    Validate.isTrue(directory.isDirectory(), "Directory must be a directory");

    List<Addon> result = new ArrayList<>();

    for (File file : directory.listFiles()) {
        if (!JAR_PATTERN.matcher(file.getName()).matches()) continue;

        try {
            result.add(this.loadAddon(file));
        } catch (InvalidAddonException e) {
            AddonCore.getLogger().log(Level.SEVERE,
                    "Cannot load '" + file.getName() + "' in folder '" + directory.getPath() + "': " + e.getMessage());
        }
    }

    return result.toArray(new Addon[result.size()]);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:21,代码来源:SimpleAddonManager.java

示例4: adminUserCanPutAndGetEverywhere

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
private static void adminUserCanPutAndGetEverywhere() throws Exception {
  String valueFromRegion;
  try (Example example = new Example("superUser")) {
    // All puts and gets should pass
    example.region1.put(AUTHOR_ABERCROMBIE, BOOK_BY_ABERCROMBIE);
    example.region2.put(AUTHOR_GROSSMAN, BOOK_BY_GROSSMAN);

    valueFromRegion = example.region1.get(AUTHOR_ABERCROMBIE);
    Validate.isTrue(BOOK_BY_ABERCROMBIE.equals(valueFromRegion));

    valueFromRegion = example.region2.get(AUTHOR_GROSSMAN);
    Validate.isTrue(BOOK_BY_GROSSMAN.equals(valueFromRegion));
  }
}
 
开发者ID:apache,项目名称:geode-examples,代码行数:15,代码来源:Example.java

示例5: registerNewObjective

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException {
    Validate.notNull(name, "Objective name cannot be null");
    Validate.notNull(criteria, "Criteria cannot be null");
    Validate.isTrue(name.length() <= 16, "The name '" + name + "' is longer than the limit of 16 characters");
    Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists");

    CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
    net.minecraft.scoreboard.ScoreObjective objective = board.addScoreObjective(name, craftCriteria.criteria);
    return new CraftObjective(this, objective);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftScoreboard.java

示例6: setSuffix

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public void setSuffix(String suffix) throws IllegalStateException, IllegalArgumentException {
    Validate.notNull(suffix, "Suffix cannot be null");
    Validate.isTrue(suffix.length() <= 32, "Suffix '" + suffix + "' is longer than the limit of 32 characters");
    CraftScoreboard scoreboard = checkState();

    team.setNameSuffix(suffix);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:8,代码来源:CraftTeam.java

示例7: assignFairly

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
/**
 * 公平的分配 task 到对应的 taskGroup 中。
 * 公平体现在:会考虑 task 中对资源负载作的 load 标识进行更均衡的作业分配操作。
 * TODO 具体文档举例说明
 */
public static List<Configuration> assignFairly(Configuration configuration, int channelNumber, int channelsPerTaskGroup) {
    Validate.isTrue(configuration != null, "框架获得的 Job 不能为 null.");

    List<Configuration> contentConfig = configuration.getListConfiguration(CoreConstant.DATAX_JOB_CONTENT);
    Validate.isTrue(contentConfig.size() > 0, "框架获得的切分后的 Job 无内容.");

    Validate.isTrue(channelNumber > 0 && channelsPerTaskGroup > 0,
            "每个channel的平均task数[averTaskPerChannel],channel数目[channelNumber],每个taskGroup的平均channel数[channelsPerTaskGroup]都应该为正数");

    int taskGroupNumber = (int) Math.ceil(1.0 * channelNumber / channelsPerTaskGroup);

    Configuration aTaskConfig = contentConfig.get(0);

    String readerResourceMark = aTaskConfig.getString(CoreConstant.JOB_READER_PARAMETER + "." +
            CommonConstant.LOAD_BALANCE_RESOURCE_MARK);
    String writerResourceMark = aTaskConfig.getString(CoreConstant.JOB_WRITER_PARAMETER + "." +
            CommonConstant.LOAD_BALANCE_RESOURCE_MARK);

    boolean hasLoadBalanceResourceMark = StringUtils.isNotBlank(readerResourceMark) ||
            StringUtils.isNotBlank(writerResourceMark);

    if (!hasLoadBalanceResourceMark) {
        // fake 一个固定的 key 作为资源标识(在 reader 或者 writer 上均可,此处选择在 reader 上进行 fake)
        for (Configuration conf : contentConfig) {
            conf.set(CoreConstant.JOB_READER_PARAMETER + "." +
                    CommonConstant.LOAD_BALANCE_RESOURCE_MARK, "aFakeResourceMarkForLoadBalance");
        }
        // 是为了避免某些插件没有设置 资源标识 而进行了一次随机打乱操作
        Collections.shuffle(contentConfig, new Random(System.currentTimeMillis()));
    }

    LinkedHashMap<String, List<Integer>> resourceMarkAndTaskIdMap = parseAndGetResourceMarkAndTaskIdMap(contentConfig);
    List<Configuration> taskGroupConfig = doAssign(resourceMarkAndTaskIdMap, configuration, taskGroupNumber);

    // 调整 每个 taskGroup 对应的 Channel 个数(属于优化范畴)
    adjustChannelNumPerTaskGroup(taskGroupConfig, channelNumber);
    return taskGroupConfig;
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:44,代码来源:JobAssignUtil.java

示例8: registerNewTeam

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public Team registerNewTeam(String name) throws IllegalArgumentException {
    Validate.notNull(name, "Team name cannot be null");
    Validate.isTrue(name.length() <= 16, "Team name '" + name + "' is longer than the limit of 16 characters");
    Validate.isTrue(board.getTeam(name) == null, "Team name '" + name + "' is already in use");

    return new CraftTeam(this, board.createTeam(name));
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:8,代码来源:CraftScoreboard.java

示例9: spawnFallingBlock

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(material.isBlock(), "Material must be a block");

    double x = location.getBlockX() + 0.5;
    double y = location.getBlockY() + 0.5;
    double z = location.getBlockZ() + 0.5;

    net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
    entity.field_145812_b = 1; // ticksLived

    world.addEntity(entity, SpawnReason.CUSTOM);
    return (FallingBlock) entity.getBukkitEntity();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftWorld.java

示例10: checkIfCleanBuildShouldProceed

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
private void checkIfCleanBuildShouldProceed(Environment env, boolean noPrompt) {
    LOG.info("Request was made to clean the environment...");

    Validate.isTrue(env.isCleanBuildAllowed(), "Clean build not allowed for this environment [" + env.getName()
            + "] ! Exiting...");

    if (!noPrompt) {
        LOG.info("WARNING - This will wipe the whole environment!!! Are you sure you want to proceed? (Y/N)");

        String input = this.userInputReader.readLine(null);
        Validate.isTrue(input.trim().equalsIgnoreCase("Y"), "User did not enter Y. Hence, we will exit from here.");
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:14,代码来源:DbDeployerMain.java

示例11: setStatistic

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
@Override
public void setStatistic(Statistic statistic, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
    getHandle().func_147099_x().func_150873_a(getHandle(), nmsStatistic, newValue);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:9,代码来源:CraftPlayer.java

示例12: MinecraftInventory

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public MinecraftInventory(InventoryHolder owner, int size, String title) {
    Validate.notNull(title, "Title cannot be null");
    Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
    this.items = new net.minecraft.item.ItemStack[size];
    this.title = title;
    this.viewers = new ArrayList<HumanEntity>();
    this.owner = owner;
    this.type = InventoryType.CHEST;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:10,代码来源:CraftInventoryCustom.java

示例13: getLevelForExp

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
/**
 * Get the level that the given amount of XP falls within.
 *
 * @param exp the amount to check for
 * @return the level that a player with this amount total XP would be
 * @throws IllegalArgumentException if the given XP is less than 0
 */
public int getLevelForExp(int exp) {
    if (exp <= 0) {
        return 0;
    }
    if (exp > xpTotalToReachLevel[xpTotalToReachLevel.length - 1]) {
        // need to extend the lookup tables
        int newMax = calculateLevelForExp(exp) * 2;
        Validate.isTrue(newMax <= hardMaxLevel, "Level for exp " + exp + " > hard max level " + hardMaxLevel);
        initLookupTables(newMax);
    }
    int pos = Arrays.binarySearch(xpTotalToReachLevel, exp);
    return pos < 0 ? -pos - 2 : pos;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:21,代码来源:ExperienceManager.java

示例14: BarrelParticleForm

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
public BarrelParticleForm(Effect effect, EffectData<?> effectData, Location location, String axis, double dense, double depth, double radius, BlockFace direction) {
    super(location, axis, dense, depth, radius, direction, null);

    if (effectData != null)
        Validate.isTrue(effect.getData() != null && effect.getData().isAssignableFrom(effectData.getDataValue().getClass()), "Wrong kind of effectData for this effect!");
    else {
        Validate.isTrue(effect.getData() == null, "Wrong kind of effectData for this effect!");
        effectData = new EffectData<>(null);
    }

    EffectData<?> finalEffectData = effectData;

    setAction((p, loc) -> p.playEffect(loc, effect, finalEffectData.getDataValue()));
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:15,代码来源:BarrelParticleForm.java

示例15: decrementStatistic

import org.apache.commons.lang.Validate; //导入方法依赖的package包/类
@Override
public void decrementStatistic(Statistic statistic, int amount) {
    Validate.isTrue(amount > 0, "Amount must be greater than 0");
    setStatistic(statistic, getStatistic(statistic) - amount);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:6,代码来源:CraftPlayer.java


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