001package com.google.common.base;
002
003import static com.google.common.base.Preconditions.format;
004import javax.annotation.Nullable;
005
006import gu.sql2java.BaseColumnStore.URLParseException;
007
008/**
009 * URL解析检查工具类
010 * @author guyadong
011 *
012 */
013public class URLParseChecks {
014
015        public URLParseChecks() {
016        }
017        /**
018         * 执行表达式,为false时抛出{@link URLParseException}异常
019         * @param b
020         * @param errorMessageTemplate a template for the exception message should the check fail. The
021         *     message is formed by replacing each {@code %s} placeholder in the template with an
022         *     argument. These are matched by position - the first {@code %s} gets {@code
023         *     errorMessageArgs[0]}, etc. Unmatched arguments will be appended to the formatted message in
024         *     square braces. Unmatched placeholders will be left as-is.
025         * @param errorMessageArgs the arguments to be substituted into the message template. Arguments
026         *     are converted to strings using {@link String#valueOf(Object)}.
027         * @throws URLParseException
028         */
029        public static void checkURLParse(
030                        boolean b, 
031                        @Nullable String errorMessageTemplate, 
032                        @Nullable Object... errorMessageArgs) throws URLParseException {
033                if (!b) {
034                        throw new URLParseException(format(errorMessageTemplate, errorMessageArgs));
035                }
036        }
037        /**
038         * 执行表达式,为false时抛出{@link URLParseException}异常
039         *
040         * <p>See {@link #checkURLParse(boolean, String, Object...)} for details.
041         * @throws URLParseException 
042         */
043        public static void checkURLParse(
044                        boolean b, 
045                        @Nullable String errorMessageTemplate, @Nullable Object p1) throws URLParseException {
046                if (!b) {
047                        throw new URLParseException(format(errorMessageTemplate, p1));
048                }
049        }
050}