Bean clone and Replication

Source: Internet
Author: User


@ Test
Public void testCopy (){
BeanCopier copy = BeanCopier. create (Bean. class, Bean2.class,
False );
Bean source = new Bean ();
Source. setIpaddr ("12.16.17.18 ");
Source. setPin (1568 );
Bean2 target = null;
Long t = System. currentTimeMillis ();
For (int I = 0; I <10000000; I ++ ){
Target = new Bean2 ();
Copy. copy (source, target, null );
}
System. out. println (System. currentTimeMillis ()-t );
System. out. println (target. getIpArr ());
// System. out. println (target. getIpArr (). size ());
System. out. println (target. getIpaddr ());
}


Class Bean {
Private String ipaddr;
Private Integer pin;


Public String getIpaddr (){
Return ipaddr;
}


Public void setIpaddr (String ipaddr ){
This. ipaddr = ipaddr;
}


Public Integer getPin (){
Return pin;
}


Public void setPin (Integer pin ){
This. pin = pin;
}


}


Class Bean2 {
Private List <String> ipArr = new ArrayList <String> (); // IP address List
Private Integer pin;
Private String ipaddr;


Public String getIpaddr (){
Return ipaddr;
}


Public void setIpaddr (String ipaddr ){
If (ipaddr = null)
Return;
// Matcher m = ps. matcher (ipaddr );
// While (m. find ())
// IpArr. add (m. group ());
// String [] iplist = ipaddr. split (".",-1 );
// For (String ip: iplist ){
// IpArr. add (m. group ());
// IpArr. add ("34 ");
// IpArr. add ("35 ");
//}


This. ipaddr = ipaddr;
}


Public List <String> getIpArr (){
Return ipArr;
}


Public void setIpArr (List <String> ipArr ){
This. ipArr = ipArr;
}


Public Integer getPin (){
Return pin;
}


Public void setPin (Integer pin ){
This. pin = pin;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.