zoukankan      html  css  js  c++  java
  • java 异常

    参数为空,抛这个异常IllegalArgumentException

    public static void notNull(Object object, String message) {
    if (object == null) {
    throw new IllegalArgumentException(message);
    }
    }

    状态异常,一般参数为false,或者converter instanceof ConditionalConverter为false,

    参数不满足条件的时候就跑出IllegalStateException异常

    public void add(Iterator<E> iterator) {
    Assert.state(!this.inUse, "You can no longer add iterators to a composite iterator that's already in use");
    if (this.iterators.contains(iterator)) {
    throw new IllegalArgumentException("You cannot add the same iterator twice");
    }
    this.iterators.add(iterator);
    }

    public void add(GenericConverter converter) {
    Set<ConvertiblePair> convertibleTypes = converter.getConvertibleTypes();
    if (convertibleTypes == null) {
    Assert.state(converter instanceof ConditionalConverter,
    "Only conditional converters may return null convertible types");
    this.globalConverters.add(converter);
    }
    else {
    for (ConvertiblePair convertiblePair : convertibleTypes) {
    ConvertersForPair convertersForPair = getMatchableConverters(convertiblePair);
    convertersForPair.add(converter);
    }
    }
    }

    public int compare(T o1, T o2) {
    Assert.state(this.comparators.size() > 0,
    "No sort definitions have been added to this CompoundComparator to compare");
    for (InvertibleComparator comparator : this.comparators) {
    int result = comparator.compare(o1, o2);
    if (result != 0) {
    return result;
    }
    }
    return 0;
    }

  • 相关阅读:
    c语言中统计字符串中数字出现的次数
    tyvj1294 小v的舞会
    tyvj1114 搭建双塔
    tyvj1193 括号序列
    tyvj1113 魔族密码
    tyvj1102 单词的划分
    tyvj1097 mm不哭
    tyvj1189 盖房子
    tyvj1098 任务安排
    tyvj1144 股票
  • 原文地址:https://www.cnblogs.com/handsome1013/p/7249277.html
Copyright © 2011-2022 走看看