Skip to content

Commit

Permalink
write a line into test.file
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Jan 18, 2025
1 parent 1e89e62 commit c03951b
Show file tree
Hide file tree
Showing 10 changed files with 655 additions and 0 deletions.
64 changes: 64 additions & 0 deletions docs/spring/cs95e5e7da-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.mapping;

import org.apache.ibatis.session.Configuration;

import java.util.Collections;
import java.util.Map;

/**
* @author Clinton Begin
*/
public class Discriminator {

private ResultMapping resultMapping;
private Map<String, String> discriminatorMap;

Discriminator() {
}

public ResultMapping getResultMapping() {
return resultMapping;
}

public Map<String, String> getDiscriminatorMap() {
return discriminatorMap;
}

public String getMapIdFor(String s) {
return discriminatorMap.get(s);
}

public static class Builder {
private Discriminator discriminator = new Discriminator();

public Builder(Configuration configuration, ResultMapping resultMapping, Map<String, String> discriminatorMap) {
discriminator.resultMapping = resultMapping;
discriminator.discriminatorMap = discriminatorMap;
}

public Discriminator build() {
assert discriminator.resultMapping != null;
assert discriminator.discriminatorMap != null;
assert !discriminator.discriminatorMap.isEmpty();
//lock down map
discriminator.discriminatorMap = Collections.unmodifiableMap(discriminator.discriminatorMap);
return discriminator;
}
}

}
30 changes: 30 additions & 0 deletions docs/spring/cs9619c1ea-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.huifer.aop.advisor;

import org.springframework.aop.ClassFilter;

/**
* 描述:
* 类过滤器
*
* @author huifer
* @date 2019-03-03
*/
public class MyClassFilter implements ClassFilter {
/***
* 判断当前实现类是否是我们的织入所相关的类
* 本次案例中 男性上厕所不需要带纸巾,女性上厕所需要带纸巾,
* 那么BaseAopPointCut接口应该要对女性进行判断,完成此步骤后还需要一个方法匹配器 ,
* 再次我们只要对上厕所匹配 吃饭不需要匹配
*
* @param aClass 当前被拦截的类
* @return boolean
*/
@Override
public boolean matches(Class<?> aClass) {
if (aClass == WoMan.class) {

return true;
}
return false;
}
}
86 changes: 86 additions & 0 deletions docs/spring/cs96535a0e-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.submitted.use_actual_param_name;

import org.apache.ibatis.BaseDataTest;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.Reader;
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class UseActualParamNameTest {

private static SqlSessionFactory sqlSessionFactory;

@BeforeAll
static void setUp() throws Exception {
// create an SqlSessionFactory
try (Reader reader = Resources.getResourceAsReader(
"org/apache/ibatis/submitted/use_actual_param_name/mybatis-config.xml")) {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
}

// populate in-memory database
BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(),
"org/apache/ibatis/submitted/use_actual_param_name/CreateDB.sql");
}

@Test
void shouldSingleParamBeReferencedByAnyName() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
User user = mapper.getUserById(1);
assertNotNull(user);
}
}

@Test
void shouldMultipleParamsBeReferencedByActualNames() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
User user = mapper.getUserByIdAndName(1, "User1");
assertNotNull(user);
}
}

@Test
void shouldSoleListParamBeReferencedByImplicitName() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
List<User> users = mapper.getUsersByIdList(Arrays.asList(1, 2));
assertEquals(2, users.size());
}
}

@Test
void shouldListParamBeReferencedByActualNameIfAnotherParamExists() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
List<User> users = mapper.getUsersByIdListAndName(Arrays.asList(1, 2), null);
assertEquals(2, users.size());
}
}

}
38 changes: 38 additions & 0 deletions docs/spring/cs968272e4-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.submitted.duplicate_statements;

public class User {

private Integer id;
private String name;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
24 changes: 24 additions & 0 deletions docs/spring/cs96b321dc-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.session;

/**
* 本地缓存作用域
* @author Eduardo Macarron
*/
public enum LocalCacheScope {
SESSION, STATEMENT
}
42 changes: 42 additions & 0 deletions docs/spring/cs96e0e05e-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright 2009-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.type;

/**
* @author Clinton Begin
*/
class ByteArrayUtils {

private ByteArrayUtils() {
// Prevent Instantiation
}

static byte[] convertToPrimitiveArray(Byte[] objects) {
final byte[] bytes = new byte[objects.length];
for (int i = 0; i < objects.length; i++) {
bytes[i] = objects[i];
}
return bytes;
}

static Byte[] convertToObjectArray(byte[] bytes) {
final Byte[] objects = new Byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
objects[i] = bytes[i];
}
return objects;
}
}
47 changes: 47 additions & 0 deletions docs/spring/cs971917da-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.submitted.constructor_automapping;

public class Article {

private Integer id;
private String title;
private Author author;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Author getAuthor() {
return author;
}

public void setAuthor(Author author) {
this.author = author;
}
}
38 changes: 38 additions & 0 deletions docs/spring/cs97533e2e-d53c-11ef-b299-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2009-2018 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 org.apache.ibatis.submitted.lazyload_proxyfactory_comparison;

public class Group {

private Integer id;
private String name;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Loading

0 comments on commit c03951b

Please sign in to comment.