Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,8 @@
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No star imports, please.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.CacheNamespace;
Expand Down Expand Up @@ -487,12 +478,9 @@ private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterT
}

private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
final StringBuilder sql = new StringBuilder();
for (String fragment : strings) {
sql.append(fragment);
sql.append(" ");
}
return languageDriver.createSqlSource(configuration, sql.toString().trim(), parameterTypeClass);
final String sql = Arrays.stream(strings).map(fragment -> fragment + " ").collect(Collectors.joining());

return languageDriver.createSqlSource(configuration, sql.trim(), parameterTypeClass);
}

private SqlCommandType getSqlCommandType(Method method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Stream;

import org.apache.ibatis.builder.BaseBuilder;
import org.apache.ibatis.builder.BuilderException;
Expand Down Expand Up @@ -394,9 +395,7 @@ private ResultMapping buildResultMappingFromContext(XNode context, Class<?> resu
}

private String processNestedResultMappings(XNode context, List<ResultMapping> resultMappings, Class<?> enclosingType) throws Exception {
if ("association".equals(context.getName())
|| "collection".equals(context.getName())
|| "case".equals(context.getName())) {
if (Stream.of("association", "collection", "case").anyMatch(s -> s.equals(context.getName()))) {
if (context.getStringAttribute("select") == null) {
validateCollection(context, enclosingType);
ResultMap resultMap = resultMapElement(context, resultMappings, enclosingType);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/apache/ibatis/io/JBoss6VFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
Expand Down Expand Up @@ -56,10 +57,9 @@ String getPathNameRelativeTo(VirtualFile parent) {

List<VirtualFile> getChildren() throws IOException {
List<?> objects = invoke(getChildrenRecursively, virtualFile);
List<VirtualFile> children = new ArrayList<>(objects.size());
for (Object object : objects) {
children.add(new VirtualFile(object));
}
List<VirtualFile> children = objects.stream()
.map(JBoss6VFS.VirtualFile::new)
.collect(Collectors.toCollection(() -> new ArrayList<>(objects.size())));
return children;
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/apache/ibatis/type/ByteArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.apache.ibatis.type;

import java.util.stream.IntStream;

/**
* @author Clinton Begin
*/
Expand All @@ -33,10 +35,7 @@ static byte[] convertToPrimitiveArray(Byte[] objects) {
}

static Byte[] convertToObjectArray(byte[] bytes) {
final Byte[] objects = new Byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
objects[i] = bytes[i];
}
final Byte[] objects = IntStream.range(0, bytes.length).mapToObj(i -> bytes[i]).toArray(Byte[]::new);
return objects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.apache.ibatis.domain.blog;

import java.util.Objects;

public class ComplexImmutableAuthorId {
protected final int id;
protected final String email;
Expand Down Expand Up @@ -58,13 +60,13 @@ public boolean equals(Object o) {
if (id != that.id) {
return false;
}
if (email != null ? !email.equals(that.email) : that.email != null) {
if (!Objects.equals(email, that.email)) {
return false;
}
if (password != null ? !password.equals(that.password) : that.password != null) {
if (!Objects.equals(password, that.password)) {
return false;
}
if (username != null ? !username.equals(that.username) : that.username != null) {
if (!Objects.equals(username, that.username)) {
return false;
}

Expand Down