=====自动生成toString()方法===========================================
=====自动生成compareTo()方法===========================================
注:本方法忽略静态字段和瞬时字段
自定义compareTo()
=====复制数组和反转数组===========================================
Original: { 1, 3, 2, 3, 5, 6 } Reversed: { 6, 5, 3, 2, 3, 1 }
=====查找数组中元素===========================================
Array contains 'Blue'? true Index of 'Red'? 0 Last Index of 'Red'? 4
=====格式化日期===========================================
It is currently: 2004-03-26T16:20:00-07:00
Name | Format |
---|---|
ISO_DATE_FORMAT | yyyy-MM-dd"2004-01-02" |
ISO_DATE_TIME_ZONE_FORMAT | yyyy-MM-ddZZ"2004-01-02-07:00" |
ISO_DATETIME_FORMAT | yyyy-MM-dd'T'HH:mm:ss"2004-01-02T23:22:12" |
ISO_DATETIME_TIME_ZONE_FORMAT | yyyy-MM-dd'T'HH:mm:ssZZ"2004-01-02T21:13:45-07:00" |
ISO_TIME_FORMAT | 'T'HH:mm:ss"T04:23:22" |
ISO_TIME_NO_T_FORMAT | HH:mm:ss"05:12:34" |
ISO_TIME_NO_T_TIME_ZONE_FORMAT | HH:mm:ssZZ"12:32:22-07:00" |
ISO_TIME_TIME_ZONE_FORMAT | 'T'HH:mm:ssZZ"T18:23:22-07:00" |
SMTP_DATETIME_FORMAT | EEE, dd MMM yyyy HH:mm:ss Z"Wed, 01 Feb 2004 20:03:01 CST" |
=====四舍五入日期===========================================
Now: 2004-03-28T13:48:12 Nearest Hour: 2004-03-28T14:00:00 Nearest Day: 2004-03-29T00:00:00 Nearest Year: 2004-01-01T00:00:00
=====截断日期(向下取整)===========================================
Now: 2004-03-28T13:48:12 Truncated Month: 2004-03-01T00:00:00 Truncated Hour: 2004-03-28T13:00:00
=====检查方法的参数===========================================
Validate method | Description |
---|---|
isTrue(boolean expr) | Fails if expression evaluates to false |
isTrue(boolean expr, String msg) | Same as above; constructs exception with a message |
noNullElements(Collection col) | Fails if collection contains a null |
noNullElements(Object[] array) | Fails if array contains a null |
notEmpty(Collection col) | Fails if collection is empty |
notEmpty(Map map) | Fails if map is empty |
notEmpty(Object[] array) | Fails if array is empty |
notNull(Object obj) | Fails if object is null |
=====计算时间===========================================
Split Time after 1 sec: 1001
Split Time after 2 sec: 1001
Time after 3 sec: 3004
=====检查字符串是否为空==========================================
test blank? true test2 blank? true test3 blank? true test4 blank? false
=====简略字符串===========================================
This is... Test
The word 'ground' in context: ...the absence of firm ground - something w...
=====切割字符串===========================================
{Frantically,oblong}
2
{Pharmacy,asket,all,funky}
4
Pharmacy
asket
{Pharmacy,asketball,funky}
2
Pharmacy
=====查找特定字符串内的字符串===========================================
Variable: {45}, {35}, {120}, Sum: 200
=====修剪字符为null===========================================
=====清楚一行最后的换行符(跨平台了)===========================================
* StringUtils.chomp(null) = null
* StringUtils.chomp("") = ""
* StringUtils.chomp("abc /r") = "abc "
* StringUtils.chomp("abc/n") = "abc"
* StringUtils.chomp("abc/r/n") = "abc"
* StringUtils.chomp("abc/r/n/r/n") = "abc/r/n"
* StringUtils.chomp("abc/n/r") = "abc/n"
* StringUtils.chomp("abc/n/rabc") = "abc/n/rabc"
* StringUtils.chomp("/r") = ""
* StringUtils.chomp("/n") = ""
* StringUtils.chomp("/r/n") = ""
=====使用StringUtils.repeat() , StringUtils.center( )和StringUtils.join( )===============
****************************** ************ TEST ************ ******************************
=====反转字符串===========================================
Original: In time, I grew tired of his babbling nonsense. Reverse: .esnesnon gnilbbab sih fo derit werg I ,emit nI Original: AACGTCCCTTGGTTTCCCAAAGTTTCCCTTTGAAATATATGCCCGCG Reverse: GCGCCCGTATATAAAGTTTCCCTTTGAAACCCTTTGGTTCCCTGCAA
I am Susan. Susan am I.
=====截断字符换行方法===========================================
Wrapped Message: One Two Three Four Five
Four score and seven years ago, our fathers brought forth upon this continent a new nation: conceived in liberty, and dedicated to the proposition that all men are created equal. http://www.oreilly.com/Gettysburg
=====检查字符串是否只包含字母,或只包含数字,或两者都有=====================================
=====计算一个子字符串在一个大的字符串出现过多少次===========================================
=====解释格式化了的字符串===========================================
=====比较两个字符串不同的地方===========================================
Edit Distance: 2 Difference: ld Diff Index: 3
=====访问javabean的简单属性===========================================
=====访问内嵌的javabean属性===========================================
=====访问属性是列表的javabean属性===========================================
=====访问属性是map的javabean属性==========================================
=====综合访问javabean属性例子===========================================
=====确定javabean属性类型===========================================
=====比较javabean(compareTo())===========================================
Sorted Countries: Country: Afghanistan Country: India Country: Pakistan
=====复制javabean属性===========================================
bean to bean 的复制
map to bean 的复制
=====克隆bean===========================================
=====设置bean属性===========================================
=====检查bean的可访问性===========================================
=====用Predicates检查bean的属性===========================================
=====将bean属性转化为map===========================================
=====动态生成javabean===========================================
=====用String设置、读取bean的属性===========================================
=====反转Comparator===========================================
=====多个Comparator(comparatorChain)===========================================
=====NullComparator===========================================
=====自定义排序(扑克排序例子,综合应用)===========================================
=====简单的Predicate()基于一定的前提条件得到满足,并且要在对象中封装了件。================
Name | Description |
---|---|
EqualPredicate | Compares each object to an object passed via a constructor—returning true if the two are equal. |
IdentityPredicate | Returns true if the object being evaluated is the same object reference as the object passed to its constructor. The IdentityPredicate uses the == operator to compare two object references. |
NotPredicate | Wraps a Predicate and returns the opposite result. |
InstanceOfPredicate | Returns true if the object being evaluated matches the type passed into its constructor. |
NullPredicateNullIsTruePredicate | Returns true if the object being evaluated is null. |
NotNullPredicateNullIsFalsePredicate | Returns true if the object being evaluated is not null. |
TruePredicate | Always returns true. |
FalsePredicate | Always returns false. |
UniquePredicate | Returns true if it is the first time a particular object has been evaluated. The UniquePredicate maintains a HashSet of objects it has evaluated; if an object is already in that HashSet, this Predicate returns false. UniquePredicate can be used to select distinct objects from a collection. |
=====自定义Predicate接口===========================================
=====使用ChainedTransformer用来建立一个转换链===========================================
=====使用闭包Closure===========================================
=====使用闭包链===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================
=====自动生成toString()方法===========================================