Skip to content

Commit

Permalink
Merge pull request #64 from alibaba/develop
Browse files Browse the repository at this point in the history
Fix some typos (alibaba#11269)
  • Loading branch information
Wuyunfan-BUPT authored Nov 7, 2023
2 parents 4a95836 + 0d46af0 commit 5f19c61
Show file tree
Hide file tree
Showing 52 changed files with 1,672 additions and 872 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public boolean validate() {
continue;
}

for (int i = 0; i < host.getWeight(); i++) {
if (host.getWeight() > 0) {
validHosts.add(host);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.packagescan.util.PathMatcher;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.StringUtils;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractObjectUtils;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractObjectUtils;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.ClassUtils;
import com.alibaba.nacos.common.utils.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.packagescan.util.ResourceUtils;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.ClassUtils;
import com.alibaba.nacos.common.utils.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.StringUtils;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.alibaba.nacos.common.packagescan.util.PathMatcher;
import com.alibaba.nacos.common.packagescan.util.ResourceUtils;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.ClassUtils;
import com.alibaba.nacos.common.utils.ReflectUtils;
import com.alibaba.nacos.common.utils.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.packagescan.util.ResourceUtils;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.utils.StringUtils;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.alibaba.nacos.common.packagescan.resource;

import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.AbstractAssert;
import com.alibaba.nacos.common.packagescan.util.NestedIoException;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,7 +14,10 @@
* limitations under the License.
*/

package com.alibaba.nacos.common.utils;
package com.alibaba.nacos.common.packagescan.util;

import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.StringUtils;

import java.util.Collection;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.alibaba.nacos.common.utils;
package com.alibaba.nacos.common.packagescan.util;

import java.lang.reflect.Array;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.alibaba.nacos.common.packagescan.util;

import com.alibaba.nacos.common.packagescan.resource.Resource;
import com.alibaba.nacos.common.utils.AbstractAssert;
import com.alibaba.nacos.common.utils.ClassUtils;
import com.alibaba.nacos.common.utils.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public final class ClassUtils {

private ClassUtils() {
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public static String getSimpleName(Object obj) {
*/
public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError {

AbstractAssert.notNull(name, "Name must not be null");
Objects.requireNonNull(name, "Name must not be null");

Class<?> clazz = resolvePrimitiveClassName(name);
if (clazz == null) {
Expand Down Expand Up @@ -386,7 +386,7 @@ public static String classPackageAsResourcePath(Class<?> clazz) {
* @return the corresponding resource path, pointing to the class
*/
public static String convertClassNameToResourcePath(String className) {
AbstractAssert.notNull(className, "Class name must not be null");
Objects.requireNonNull(className, "Class name must not be null");
return className.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
}

Expand All @@ -397,7 +397,7 @@ public static String convertClassNameToResourcePath(String className) {
* @return the corresponding resource path, pointing to the class
*/
public static String resourcePathToConvertClassName(String className) {
AbstractAssert.notNull(className, "Class name must not be null");
Objects.requireNonNull(className, "Class name must not be null");
return className.replace(PATH_SEPARATOR, PACKAGE_SEPARATOR);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/**
* Copyright 2018-2021 Dynatrace LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2018-2021 Dynatrace LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and limitations under the
* License.
*/

package com.alibaba.nacos.common.utils;
Expand All @@ -22,7 +18,7 @@
*/
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName", "PMD.ClassNamingShouldBeCamelRule"})
public class InetAddressValidator {

private InetAddressValidator() {
}

Expand Down Expand Up @@ -59,9 +55,8 @@ private InetAddressValidator() {
.compile("^" + "(?:[0-9a-fA-F]{1,4}:){6}" + "$");

/**
* Check if <code>input</code> is a valid IPv4 address.
* The format is 'xxx.xxx.xxx.xxx'. Four blocks of integer numbers ranging from 0 to 255
* are required. Letters are not allowed.
* Check if <code>input</code> is a valid IPv4 address. The format is 'xxx.xxx.xxx.xxx'. Four blocks of integer
* numbers ranging from 0 to 255 are required. Letters are not allowed.
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv4 notation.
Expand All @@ -71,9 +66,8 @@ public static boolean isIPv4Address(final String input) {
}

/**
* Check if the given address is a valid IPv6 address in the standard format
* The format is 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx'. Eight blocks of hexadecimal digits
* are required.
* Check if the given address is a valid IPv6 address in the standard format The format is
* 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx'. Eight blocks of hexadecimal digits are required.
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv6 notation.
Expand All @@ -83,9 +77,8 @@ public static boolean isIPv6StdAddress(final String input) {
}

/**
* Check if the given address is a valid IPv6 address in the hex-compressed notation
* The format is 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx'. If all digits in a block are '0'
* the block can be left empty.
* Check if the given address is a valid IPv6 address in the hex-compressed notation The format is
* 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx'. If all digits in a block are '0' the block can be left empty.
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv6 (hex-compressed) notation.
Expand All @@ -95,13 +88,8 @@ public static boolean isIPv6HexCompressedAddress(final String input) {
}

/**
* Check if <code>input</code> is a IPv6 address.
* Possible notations for valid IPv6 are:
* - Standard IPv6 address
* - Hex-compressed IPv6 address
* - Link-local IPv6 address
* - IPv4-mapped-to-IPV6 address
* - IPv6 mixed address
* Check if <code>input</code> is a IPv6 address. Possible notations for valid IPv6 are: - Standard IPv6 address -
* Hex-compressed IPv6 address - Link-local IPv6 address - IPv4-mapped-to-IPV6 address - IPv6 mixed address
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv6 notation.
Expand All @@ -112,11 +100,9 @@ public static boolean isIPv6Address(final String input) {
}

/**
* Check if the given address is a valid IPv6 address in the mixed-standard or mixed-compressed notation.
* IPV6 Mixed mode consists of two parts, the first 96 bits (up to 6 blocks of 4 hex digits) are IPv6
* the IPV6 part can be either compressed or uncompressed
* the second block is a full IPv4 address
* e.g. '0:0:0:0:0:0:172.12.55.18'
* Check if the given address is a valid IPv6 address in the mixed-standard or mixed-compressed notation. IPV6 Mixed
* mode consists of two parts, the first 96 bits (up to 6 blocks of 4 hex digits) are IPv6 the IPV6 part can be
* either compressed or uncompressed the second block is a full IPv4 address e.g. '0:0:0:0:0:0:172.12.55.18'
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv6 (mixed-standard or mixed-compressed) notation.
Expand All @@ -143,9 +129,8 @@ public static boolean isIPv6MixedAddress(final String input) {
}

/**
* Check if <code>input</code> is an IPv4 address mapped into a IPv6 address. These are
* starting with "::ffff:" followed by the IPv4 address in a dot-seperated notation.
* The format is '::ffff:d.d.d.d'
* Check if <code>input</code> is an IPv4 address mapped into a IPv6 address. These are starting with "::ffff:"
* followed by the IPv4 address in a dot-seperated notation. The format is '::ffff:d.d.d.d'
*
* @param input ip-address to check
* @return true if <code>input</code> is in correct IPv6 notation containing an IPv4 address
Expand All @@ -159,8 +144,8 @@ public static boolean isIPv6IPv4MappedAddress(final String input) {
}

/**
* Check if <code>input</code> is a link local IPv6 address starting with "fe80:" and containing
* a zone index with "%xxx". The zone index will not be checked.
* Check if <code>input</code> is a link local IPv6 address starting with "fe80:" and containing a zone index with
* "%xxx". The zone index will not be checked.
*
* @param input ip-address to check
* @return true if address part of <code>input</code> is in correct IPv6 notation.
Expand All @@ -176,27 +161,4 @@ public static boolean isLinkLocalIPv6WithZoneIndex(String input) {
return false;
}

/**
* Check if <code>input</code> is a valid IPv4 or IPv6 address.
*
* @param ipAddress ip-address to check
* @return <code>true</code> if <code>ipAddress</code> is a valid ip-address
*/
public static boolean isValidIP(String ipAddress) {
if (ipAddress == null || ipAddress.length() == 0) {
return false;
}

return isIPv4Address(ipAddress) || isIPv6Address(ipAddress);
}

/**
* get to ipv4 pattern.
*
* @return
*/
public static Pattern getIpv4Pattern() {
return IPV4_PATTERN;
}

}
Loading

0 comments on commit 5f19c61

Please sign in to comment.