Talking about the use of Java tool class Commonutils

Source: Internet
Author: User

Package com.xushouwei.cn;

Import Java.util.HashMap;

Import Java.util.Map;

Import Org.junit.Test;

Import Cn.itcast.commons.CommonUtils;

/**

* Test Commonutils class

* @author Administrator

*

*/

public class Commonutilstest {

/**

* Test: Returns a random 32-bit long string

* Commonutils class-dependent jar package

Use

* 1. Used to make ID, the primary key in the database table can not be duplicated, it is not duplicated

* 2. The activation code is not duplicated.

*

*/

@Test

public void Testuuid ()

{

String S=commonutils.uuid ();

System.out.println (s);

}

/**

* Role: To encapsulate the data in a map into a large JavaBean

* Requirements: Requires that the key name in map is the same as the property name in JavaBean

*/

@Test

public void Testtobean ()

{

1. Create a map

Map<string,object> map=new hashmap<string,object> ();

Map.put ("pid", "123");

Map.put ("PName", "Xushouwei");

Map.put ("Age", 25);

Map.put ("xxx", "male");

Create a JavaBean object of person type with data from map

Person P=commonutils.tobean (map, Person.class);

SYSTEM.OUT.PRINTLN (P);

}

}

Talking about the use of Java tool class Commonutils

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.