-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
97 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/java/com/tuyang/test/testMultiThread/FromBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.tuyang.test.testMultiThread; | ||
|
||
public class FromBean { | ||
|
||
private String id; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/java/com/tuyang/test/testMultiThread/StringToIntegerConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
package com.tuyang.test.testMultiThread; | ||
|
||
import com.tuyang.beanutils.BeanCopyConvertor; | ||
|
||
public class StringToIntegerConverter implements BeanCopyConvertor<String,Integer> { | ||
|
||
@Override | ||
public Integer convertTo(String object) { | ||
return Integer.parseInt(object); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/com/tuyang/test/testMultiThread/TestMultiThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.tuyang.test.testMultiThread; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.tuyang.beanutils.BeanCopyUtils; | ||
|
||
public class TestMultiThread { | ||
|
||
@Test | ||
public void testMultiThread() { | ||
List<Thread> threads = new ArrayList<>(); | ||
for (int i=0;i<10;i++){ | ||
threads.add(new Thread(()->{ | ||
FromBean fromBean = new FromBean(); | ||
fromBean.setId("1"); | ||
ToBean toBean = BeanCopyUtils.copyBean(fromBean, ToBean.class); | ||
System.out.println(toBean.getId()); | ||
} )); | ||
} | ||
threads.forEach(e->e.start()); | ||
threads.forEach(e-> { | ||
try { | ||
e.join(); | ||
} catch (InterruptedException e1) { | ||
e1.printStackTrace(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tuyang.test.testMultiThread; | ||
|
||
import com.tuyang.beanutils.annotation.BeanCopySource; | ||
import com.tuyang.beanutils.annotation.CopyProperty; | ||
|
||
@BeanCopySource(source=FromBean.class) | ||
public class ToBean { | ||
|
||
@CopyProperty(property="id", convertor=StringToIntegerConverter.class) | ||
private Integer id; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
} |