-
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.
IGNORE_ALL_NULL_SOURCE_VALUE for v1.0.7
- Loading branch information
Showing
10 changed files
with
196 additions
and
6 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
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
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,44 @@ | ||
package com.tuyang.test.testIgnoreAll; | ||
|
||
public class FromBean { | ||
|
||
private int beanInt; | ||
private long beanLong; | ||
|
||
private String beanString; | ||
|
||
private FromBean2 bean2; | ||
|
||
public int getBeanInt() { | ||
return beanInt; | ||
} | ||
|
||
public void setBeanInt(int beanInt) { | ||
this.beanInt = beanInt; | ||
} | ||
|
||
public long getBeanLong() { | ||
return beanLong; | ||
} | ||
|
||
public void setBeanLong(long beanLong) { | ||
this.beanLong = beanLong; | ||
} | ||
|
||
public String getBeanString() { | ||
return beanString; | ||
} | ||
|
||
public void setBeanString(String beanString) { | ||
this.beanString = beanString; | ||
} | ||
|
||
public FromBean2 getBean2() { | ||
return bean2; | ||
} | ||
|
||
public void setBean2(FromBean2 bean2) { | ||
this.bean2 = bean2; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/com/tuyang/test/testIgnoreAll/FromBean2.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,22 @@ | ||
package com.tuyang.test.testIgnoreAll; | ||
|
||
public class FromBean2 { | ||
|
||
private Float beanFloat; | ||
private String beanString; | ||
|
||
public Float getBeanFloat() { | ||
return beanFloat; | ||
} | ||
public void setBeanFloat(Float beanFloat) { | ||
this.beanFloat = beanFloat; | ||
} | ||
public String getBeanString() { | ||
return beanString; | ||
} | ||
public void setBeanString(String beanString) { | ||
this.beanString = beanString; | ||
} | ||
|
||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java/com/tuyang/test/testIgnoreAll/TestIgnoreAll.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,40 @@ | ||
package com.tuyang.test.testIgnoreAll; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.tuyang.beanutils.BeanCopyUtils; | ||
|
||
public class TestIgnoreAll { | ||
|
||
private FromBean getFromBean() { | ||
FromBean fromBean = new FromBean(); | ||
fromBean.setBeanInt(100); | ||
fromBean.setBeanLong(200); | ||
fromBean.setBeanString(null); | ||
|
||
FromBean2 bean2 = new FromBean2(); | ||
bean2.setBeanFloat(10.4f); | ||
bean2.setBeanString(null); | ||
|
||
fromBean.setBean2(bean2); | ||
|
||
return fromBean; | ||
} | ||
|
||
@Test | ||
public void testIgnoreAll() { | ||
FromBean fromBean = getFromBean(); | ||
ToBean toBean = new ToBean(); | ||
toBean.setBeanString("Not Empty"); | ||
toBean.setBean2String("Not Empty"); | ||
BeanCopyUtils.copyBean(fromBean, toBean); | ||
assertEquals( toBean.getBeanString(), "Not Empty" ); | ||
assertEquals( toBean.getBean2String(), "Not Empty" ); | ||
} | ||
} | ||
|
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,48 @@ | ||
package com.tuyang.test.testIgnoreAll; | ||
|
||
import com.tuyang.beanutils.annotation.BeanCopySource; | ||
import com.tuyang.beanutils.annotation.CopyProperty; | ||
import com.tuyang.beanutils.annotation.CopyFeature; | ||
|
||
@BeanCopySource(source=FromBean.class, features={CopyFeature.IGNORE_ALL_NULL_SOURCE_VALUE}) | ||
public class ToBean { | ||
|
||
private Integer beanInt; | ||
private long beanLong; | ||
private String beanString; | ||
|
||
@CopyProperty(property="bean2.beanString") | ||
private String bean2String; | ||
|
||
public Integer getBeanInt() { | ||
return beanInt; | ||
} | ||
|
||
public void setBeanInt(Integer beanInt) { | ||
this.beanInt = beanInt; | ||
} | ||
|
||
public long getBeanLong() { | ||
return beanLong; | ||
} | ||
|
||
public void setBeanLong(long beanLong) { | ||
this.beanLong = beanLong; | ||
} | ||
|
||
public String getBeanString() { | ||
return beanString; | ||
} | ||
|
||
public void setBeanString(String beanString) { | ||
this.beanString = beanString; | ||
} | ||
|
||
public String getBean2String() { | ||
return bean2String; | ||
} | ||
|
||
public void setBean2String(String bean2String) { | ||
this.bean2String = bean2String; | ||
} | ||
} |