public void ensureRedirectValid()

in src/main/java/com/aliyun/oss/model/RoutingRule.java [526:550]


        public void ensureRedirectValid() {
            if (hostName == null && protocol == null && replaceKeyPrefixWith == null && replaceKeyWith == null
                    && httpRedirectCode == null && mirrorURL == null) {
                throw new IllegalArgumentException(MessageFormat.format("RoutingRuleRedirectInvalid",
                        "Redirect element must contain at least one of the sibling elements"));
            }

            if (replaceKeyPrefixWith != null && replaceKeyWith != null) {
                throw new IllegalArgumentException(MessageFormat.format("RoutingRuleRedirectInvalid",
                        "ReplaceKeyPrefixWith or ReplaceKeyWith only choose one"));
            }

            if (redirectType == RedirectType.Mirror && mirrorURL == null) {
                throw new IllegalArgumentException(
                        MessageFormat.format("RoutingRuleRedirectInvalid", "MirrorURL must have a value"));
            }

            if (redirectType == RedirectType.Mirror) {
                if ((!mirrorURL.startsWith("http://") && !mirrorURL.startsWith("https://"))
                        || !mirrorURL.endsWith("/")) {
                    throw new IllegalArgumentException(
                            MessageFormat.format("RoutingRuleRedirectInvalid", "MirrorURL is invalid", mirrorURL));
                }
            }
        }