Skip to content

Commit

Permalink
Merge pull request #2796 from hazendaz/formatting
Browse files Browse the repository at this point in the history
[ci] formatting
  • Loading branch information
hazendaz committed Feb 4, 2023
2 parents e042979 + 8618782 commit 59afc18
Show file tree
Hide file tree
Showing 49 changed files with 1,231 additions and 996 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
/**
* Vendor DatabaseId provider.
* <p>
* It returns database product name as a databaseId. If the user provides a properties it uses it to
* translate database product name key="Microsoft SQL Server", value="ms" will return "ms". It can return
* null, if no database product name or a properties was specified and no translation was found.
* It returns database product name as a databaseId. If the user provides a properties it uses it to translate database
* product name key="Microsoft SQL Server", value="ms" will return "ms". It can return null, if no database product name
* or a properties was specified and no translation was found.
*
* @author Eduardo Macarron
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,8 @@ public final class SystemMetaObject {

public static final ObjectFactory DEFAULT_OBJECT_FACTORY = new DefaultObjectFactory();
public static final ObjectWrapperFactory DEFAULT_OBJECT_WRAPPER_FACTORY = new DefaultObjectWrapperFactory();
public static final MetaObject NULL_META_OBJECT = MetaObject.forObject(new NullObject(), DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY, new DefaultReflectorFactory());
public static final MetaObject NULL_META_OBJECT = MetaObject.forObject(new NullObject(), DEFAULT_OBJECT_FACTORY,
DEFAULT_OBJECT_WRAPPER_FACTORY, new DefaultReflectorFactory());

private SystemMetaObject() {
// Prevent Instantiation of Static Class
Expand All @@ -37,7 +38,8 @@ private static class NullObject {
}

public static MetaObject forObject(Object object) {
return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY, new DefaultReflectorFactory());
return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY,
new DefaultReflectorFactory());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,7 @@ public class TypeParameterResolver {
* the field
* @param srcType
* the src type
*
* @return The field type as {@link Type}. If it has type parameters in the declaration,<br>
* they will be resolved to the actual runtime {@link Type}s.
*/
Expand All @@ -53,6 +54,7 @@ public static Type resolveFieldType(Field field, Type srcType) {
* the method
* @param srcType
* the src type
*
* @return The return type of the method as {@link Type}. If it has type parameters in the declaration,<br>
* they will be resolved to the actual runtime {@link Type}s.
*/
Expand All @@ -69,6 +71,7 @@ public static Type resolveReturnType(Method method, Type srcType) {
* the method
* @param srcType
* the src type
*
* @return The parameter types of the method as an array of {@link Type}s. If they have type parameters in the
* declaration,<br>
* they will be resolved to the actual runtime {@link Type}s.
Expand All @@ -95,7 +98,8 @@ private static Type resolveType(Type type, Type srcType, Class<?> declaringClass
}
}

private static Type resolveGenericArrayType(GenericArrayType genericArrayType, Type srcType, Class<?> declaringClass) {
private static Type resolveGenericArrayType(GenericArrayType genericArrayType, Type srcType,
Class<?> declaringClass) {
Type componentType = genericArrayType.getGenericComponentType();
Type resolvedComponentType = null;
if (componentType instanceof TypeVariable) {
Expand All @@ -112,7 +116,8 @@ private static Type resolveGenericArrayType(GenericArrayType genericArrayType, T
}
}

private static ParameterizedType resolveParameterizedType(ParameterizedType parameterizedType, Type srcType, Class<?> declaringClass) {
private static ParameterizedType resolveParameterizedType(ParameterizedType parameterizedType, Type srcType,
Class<?> declaringClass) {
Class<?> rawType = (Class<?>) parameterizedType.getRawType();
Type[] typeArgs = parameterizedType.getActualTypeArguments();
Type[] args = new Type[typeArgs.length];
Expand Down Expand Up @@ -161,7 +166,8 @@ private static Type resolveTypeVar(TypeVariable<?> typeVar, Type srcType, Class<
ParameterizedType parameterizedType = (ParameterizedType) srcType;
clazz = (Class<?>) parameterizedType.getRawType();
} else {
throw new IllegalArgumentException("The 2nd arg must be Class or ParameterizedType, but was: " + srcType.getClass());
throw new IllegalArgumentException(
"The 2nd arg must be Class or ParameterizedType, but was: " + srcType.getClass());
}

if (clazz == declaringClass) {
Expand All @@ -188,7 +194,8 @@ private static Type resolveTypeVar(TypeVariable<?> typeVar, Type srcType, Class<
return Object.class;
}

private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<?> declaringClass, Class<?> clazz, Type superclass) {
private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<?> declaringClass, Class<?> clazz,
Type superclass) {
if (superclass instanceof ParameterizedType) {
ParameterizedType parentAsType = (ParameterizedType) superclass;
Class<?> parentAsClass = (Class<?>) parentAsType.getRawType();
Expand All @@ -212,7 +219,8 @@ private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<
return null;
}

private static ParameterizedType translateParentTypeVars(ParameterizedType srcType, Class<?> srcClass, ParameterizedType parentType) {
private static ParameterizedType translateParentTypeVars(ParameterizedType srcType, Class<?> srcClass,
ParameterizedType parentType) {
Type[] parentTypeArgs = parentType.getActualTypeArguments();
Type[] srcTypeArgs = srcType.getActualTypeArguments();
TypeVariable<?>[] srcTypeVars = srcClass.getTypeParameters();
Expand All @@ -230,7 +238,7 @@ private static ParameterizedType translateParentTypeVars(ParameterizedType srcTy
newParentArgs[i] = parentTypeArgs[i];
}
}
return noChange ? parentType : new ParameterizedTypeImpl((Class<?>)parentType.getRawType(), null, newParentArgs);
return noChange ? parentType : new ParameterizedTypeImpl((Class<?>) parentType.getRawType(), null, newParentArgs);
}

private TypeParameterResolver() {
Expand Down Expand Up @@ -268,7 +276,8 @@ public Type getRawType() {

@Override
public String toString() {
return "ParameterizedTypeImpl [rawType=" + rawType + ", ownerType=" + ownerType + ", actualTypeArguments=" + Arrays.toString(actualTypeArguments) + "]";
return "ParameterizedTypeImpl [rawType=" + rawType + ", ownerType=" + ownerType + ", actualTypeArguments="
+ Arrays.toString(actualTypeArguments) + "]";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,7 +68,8 @@ protected Object getCollectionValue(PropertyTokenizer prop, Object collection) {
} else if (collection instanceof short[]) {
return ((short[]) collection)[i];
} else {
throw new ReflectionException("The '" + prop.getName() + "' property of " + collection + " is not a List or Array.");
throw new ReflectionException(
"The '" + prop.getName() + "' property of " + collection + " is not a List or Array.");
}
}
}
Expand Down Expand Up @@ -99,7 +100,8 @@ protected void setCollectionValue(PropertyTokenizer prop, Object collection, Obj
} else if (collection instanceof short[]) {
((short[]) collection)[i] = (Short) value;
} else {
throw new ReflectionException("The '" + prop.getName() + "' property of " + collection + " is not a List or Array.");
throw new ReflectionException(
"The '" + prop.getName() + "' property of " + collection + " is not a List or Array.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -149,10 +149,12 @@ public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop,
Class<?> type = getSetterType(prop.getName());
try {
Object newObject = objectFactory.create(type);
metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(), metaObject.getReflectorFactory());
metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(),
metaObject.getReflectorFactory());
set(prop, newObject);
} catch (Exception e) {
throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name + "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e);
throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name
+ "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e);
}
return metaValue;
}
Expand All @@ -168,21 +170,23 @@ private Object getBeanProperty(PropertyTokenizer prop, Object object) {
} catch (RuntimeException e) {
throw e;
} catch (Throwable t) {
throw new ReflectionException("Could not get property '" + prop.getName() + "' from " + object.getClass() + ". Cause: " + t.toString(), t);
throw new ReflectionException(
"Could not get property '" + prop.getName() + "' from " + object.getClass() + ". Cause: " + t.toString(), t);
}
}

private void setBeanProperty(PropertyTokenizer prop, Object object, Object value) {
try {
Invoker method = metaClass.getSetInvoker(prop.getName());
Object[] params = {value};
Object[] params = { value };
try {
method.invoke(object, params);
} catch (Throwable t) {
throw ExceptionUtil.unwrapThrowable(t);
}
} catch (Throwable t) {
throw new ReflectionException("Could not set property '" + prop.getName() + "' of '" + object.getClass() + "' with value '" + value + "' Cause: " + t.toString(), t);
throw new ReflectionException("Could not set property '" + prop.getName() + "' of '" + object.getClass()
+ "' with value '" + value + "' Cause: " + t.toString(), t);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,8 @@ public boolean hasWrapperFor(Object object) {

@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
throw new ReflectionException("The DefaultObjectWrapperFactory should never be called to provide an ObjectWrapper.");
throw new ReflectionException(
"The DefaultObjectWrapperFactory should never be called to provide an ObjectWrapper.");
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -137,7 +137,8 @@ public boolean hasGetter(String name) {
public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
HashMap<String, Object> map = new HashMap<>();
set(prop, map);
return MetaObject.forObject(map, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(), metaObject.getReflectorFactory());
return MetaObject.forObject(map, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(),
metaObject.getReflectorFactory());
}

@Override
Expand Down
44 changes: 30 additions & 14 deletions src/main/java/org/apache/ibatis/scripting/LanguageDriver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,32 +29,48 @@ public interface LanguageDriver {
* Creates a {@link ParameterHandler} that passes the actual parameters to the the JDBC statement.
*
* @author Frank D. Martinez [mnesarco]
* @param mappedStatement The mapped statement that is being executed
* @param parameterObject The input parameter object (can be null)
* @param boundSql The resulting SQL once the dynamic language has been executed.
*
* @param mappedStatement
* The mapped statement that is being executed
* @param parameterObject
* The input parameter object (can be null)
* @param boundSql
* The resulting SQL once the dynamic language has been executed.
*
* @return the parameter handler
*
* @see DefaultParameterHandler
*/
ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);

/**
* Creates an {@link SqlSource} that will hold the statement read from a mapper xml file.
* It is called during startup, when the mapped statement is read from a class or an xml file.
* Creates an {@link SqlSource} that will hold the statement read from a mapper xml file. It is called during startup,
* when the mapped statement is read from a class or an xml file.
*
* @param configuration
* The MyBatis configuration
* @param script
* XNode parsed from a XML file
* @param parameterType
* input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be
* null.
*
* @param configuration The MyBatis configuration
* @param script XNode parsed from a XML file
* @param parameterType input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
* @return the sql source
*/
SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);

/**
* Creates an {@link SqlSource} that will hold the statement read from an annotation.
* It is called during startup, when the mapped statement is read from a class or an xml file.
* Creates an {@link SqlSource} that will hold the statement read from an annotation. It is called during startup,
* when the mapped statement is read from a class or an xml file.
*
* @param configuration
* The MyBatis configuration
* @param script
* The content of the annotation
* @param parameterType
* input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be
* null.
*
* @param configuration The MyBatis configuration
* @param script The content of the annotation
* @param parameterType input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
* @return the sql source
*/
SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,11 +22,11 @@
import org.apache.ibatis.session.Configuration;

/**
* As of 3.2.4 the default XML language is able to identify static statements
* and create a {@link RawSqlSource}. So there is no need to use RAW unless you
* want to make sure that there is not any dynamic tag for any reason.
* As of 3.2.4 the default XML language is able to identify static statements and create a {@link RawSqlSource}. So
* there is no need to use RAW unless you want to make sure that there is not any dynamic tag for any reason.
*
* @since 3.2.0
*
* @author Eduardo Macarron
*/
public class RawLanguageDriver extends XMLLanguageDriver {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,10 +26,10 @@
import org.apache.ibatis.session.Configuration;

/**
* Static SqlSource. It is faster than {@link DynamicSqlSource} because mappings are
* calculated during startup.
* Static SqlSource. It is faster than {@link DynamicSqlSource} because mappings are calculated during startup.
*
* @since 3.2.0
*
* @author Eduardo Macarron
*/
public class RawSqlSource implements SqlSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,7 +117,7 @@ public Object getProperty(Map context, Object target, Object name) {

Object parameterObject = map.get(PARAMETER_OBJECT_KEY);
if (parameterObject instanceof Map) {
return ((Map)parameterObject).get(name);
return ((Map) parameterObject).get(name);
}

return null;
Expand Down
Loading

0 comments on commit 59afc18

Please sign in to comment.