Skip to content

Commit

Permalink
Replaced String#length == 0 by String#isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
Yassin Hajaj committed Jan 9, 2024
1 parent 86d1924 commit 1a066f2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public T create(CreationalContext<T> context) {
}
} else {
Class<?> annotatedTypeClass = (Class<?>) annotated.getBaseType();
if (defaultValue.length() == 0) {
if (defaultValue.isEmpty()) {
return (T) getConfig().getValue(key, annotatedTypeClass);
} else {
Optional<T> optionalValue = (Optional<T>) getConfig().getOptionalValue(key, annotatedTypeClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public <K, V> ObjectCreator<T> map(
creator.accept(new Function<String, Object>() {
@Override
public Object apply(final String path) {
Map<String, String> mapKeys = getMapKeys(path.length() > 0 && path.charAt(path.length() - 1) == '.'
Map<String, String> mapKeys = getMapKeys(!path.isEmpty() && path.charAt(path.length() - 1) == '.'
? path.substring(0, path.length() - 1)
: path);
Map<K, V> map = defaultValue != null ? new MapWithDefault<>(defaultValue.get())
Expand Down Expand Up @@ -617,10 +617,10 @@ private Map<String, String> getMapKeys(final String name) {
Map<String, String> mapKeys = new HashMap<>();
for (String propertyName : config.getPropertyNames()) {
if (propertyName.length() > name.length() + 1
&& (name.length() == 0 || propertyName.charAt(name.length()) == '.')
&& (name.isEmpty() || propertyName.charAt(name.length()) == '.')
&& propertyName.startsWith(name)) {
// Start at the map root name
NameIterator key = name.length() > 0 ? new NameIterator(unindexed(propertyName), name.length())
NameIterator key = !name.isEmpty() ? new NameIterator(unindexed(propertyName), name.length())
: new NameIterator(unindexed(propertyName));
// Move to the next key
key.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ static boolean equals(final String name, final String other) {
return true;
}

if (name.length() == 0 && other.length() == 0) {
if (name.isEmpty() && other.isEmpty()) {
return true;
}

if (name.length() == 0 || other.length() == 0) {
if (name.isEmpty() || other.isEmpty()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public String[] getProfiles() {
}

public String normalizeName(final String name) {
if (name.length() > 0 && name.charAt(0) == '%') {
if (!name.isEmpty() && name.charAt(0) == '%') {
int profilesEnd = name.indexOf('.', 1);
int multipleSplit = -1;
for (int i = 1; i < profilesEnd; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ public Map<String, String> getMapKeys(final String name) {
Map<String, String> mapKeys = new HashMap<>();
for (String propertyName : getPropertyNames()) {
if (propertyName.length() > name.length() + 1
&& (name.length() == 0 || propertyName.charAt(name.length()) == '.')
&& (name.isEmpty() || propertyName.charAt(name.length()) == '.')
&& propertyName.startsWith(name)) {
String key = unquoted(unindexed(propertyName), name.length() == 0 ? 0 : name.length() + 1);
String key = unquoted(unindexed(propertyName), name.isEmpty() ? 0 : name.length() + 1);
mapKeys.put(key, unindexed(propertyName));
}
}
Expand Down Expand Up @@ -354,7 +354,7 @@ public <T> T convertValue(ConfigValue configValue, Converter<T> converter) {
if (converted == null) {
if (configValue.getValue() == null) {
throw new NoSuchElementException(ConfigMessages.msg.propertyNotFound(configValue.getNameProfiled())); // 2
} else if (configValue.getValue().length() == 0) {
} else if (configValue.getValue().isEmpty()) {
throw ConfigMessages.msg.propertyEmptyString(configValue.getNameProfiled(), converter.getClass().getTypeName()); // 3
} else {
throw ConfigMessages.msg.converterReturnedNull(configValue.getNameProfiled(), configValue.getValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public ConfigSourceInterceptor getInterceptor(final ConfigSourceInterceptorConte
Iterator<String> names = context.iterateNames();
while (names.hasNext()) {
String name = names.next();
if (name.length() > 0 && name.charAt(0) == '%') {
if (!name.isEmpty() && name.charAt(0) == '%') {
NameIterator ni = new NameIterator(name);
String profileSegment = ni.getNextSegment();
List<String> profiles = convertProfile(profileSegment.substring(1));
Expand Down

0 comments on commit 1a066f2

Please sign in to comment.