-
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
6 changed files
with
111 additions
and
23 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
23 changes: 23 additions & 0 deletions
23
src/test/java/com/tuyang/test/testRecursion2/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,23 @@ | ||
package com.tuyang.test.testRecursion2; | ||
|
||
public class FromBean { | ||
|
||
private String name; | ||
private FromBean parent; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public FromBean getParent() { | ||
return parent; | ||
} | ||
public void setParent(FromBean parent) { | ||
this.parent = parent; | ||
} | ||
|
||
|
||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/tuyang/test/testRecursion2/TestRecursion.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,33 @@ | ||
package com.tuyang.test.testRecursion2; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import com.tuyang.beanutils.BeanCopyUtils; | ||
|
||
public class TestRecursion { | ||
|
||
private FromBean generateBean(int i) { | ||
|
||
FromBean newBean = new FromBean(); | ||
newBean.setName("S" + i); | ||
if(i == 0) { | ||
newBean.setParent(null); | ||
} | ||
else { | ||
FromBean parentBean = generateBean(i-1); | ||
newBean.setParent(parentBean); | ||
} | ||
return newBean; | ||
} | ||
|
||
@Test | ||
public void testRecursion() { | ||
FromBean fromBean = generateBean(10); | ||
ToBean toBean = BeanCopyUtils.copyBean(fromBean, ToBean.class); | ||
assertEquals(toBean.getParent().getParent().getParent().getParent().getName(), | ||
fromBean.getParent().getParent().getParent().getParent().getName()); | ||
|
||
} | ||
} |
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,25 @@ | ||
package com.tuyang.test.testRecursion2; | ||
|
||
import com.tuyang.beanutils.annotation.BeanCopySource; | ||
import com.tuyang.beanutils.annotation.CopyProperty; | ||
|
||
@BeanCopySource(source=FromBean.class) | ||
public class ToBean { | ||
|
||
private String name; | ||
|
||
@CopyProperty(optionClass=ToBean.class) | ||
private ToBean parent; | ||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public ToBean getParent() { | ||
return parent; | ||
} | ||
public void setParent(ToBean parent) { | ||
this.parent = parent; | ||
} | ||
} |