commons-lang3 Tools Learning (II)

Three, BooleanUtils
Boolean tools

and (boolean ... array) logic and

BooleanUtils.and(true, true) = true
BooleanUtils.and(false, false) = false
BooleanUtils.and(true, false) = false
BooleanUtils.and(true, true, false) = false
BooleanUtils.and(true, true, true) = true

compare (boolean x, boolean y) compare two type int and returns a Boolean value if x == y returns 0,! x && y returns is less than 0, x &&! y is greater than 0 returns

isFalse (Boolean bool) whether it is false and returns a boolean

isTrue (Boolean bool) whether it is true and returns a boolean

negate (Boolean bool) logical negation

BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE;
BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE;
BooleanUtils.negate(null) = null;

or (boolean ... array) or a logical

BooleanUtils.or(true, true) = true
BooleanUtils.or(false, false) = false
BooleanUtils.or(true, false) = true
BooleanUtils.or(true, true, false) = true
BooleanUtils.or(true, true, true) = true
BooleanUtils.or(false, false, false) = false

toBoolean (Boolean bool) converting a basic object types and data type returned

BooleanUtils.toBoolean(Boolean.TRUE) = true
BooleanUtils.toBoolean(Boolean.FALSE) = false
BooleanUtils.toBoolean(null) = false

toBoolean (int value) will be converted to type int and returns a boolean type

BooleanUtils.toBoolean(0) = false
BooleanUtils.toBoolean(1) = true
BooleanUtils.toBoolean(2) = true

toBoolean (String str) to convert a string type and returns the boolean type

BooleanUtils.toBoolean(null) = false
BooleanUtils.toBoolean("true") = true
BooleanUtils.toBoolean("TRUE") = true
BooleanUtils.toBoolean("tRUe") = true
BooleanUtils.toBoolean("on") = true
BooleanUtils.toBoolean("yes") = true
BooleanUtils.toBoolean("false") = false
BooleanUtils.toBoolean("x gti") = false
BooleanUtils.toBooleanObject("y") = true
BooleanUtils.toBooleanObject("n") = false
BooleanUtils.toBooleanObject("t") = true
BooleanUtils.toBooleanObject("f") = false

toInteger (boolean bool) The boolean data type converted to type int and returns

BooleanUtils.toInteger ( true ) = 1 
BooleanUtils.toInteger ( false ) = 0

toStringOnOff (boolean bool) boolean type data converts a String 'on' or 'off' and return

BooleanUtils.toStringOnOff(true) = "on"
BooleanUtils.toStringOnOff(false) = "off"

toStringTrueFalse (Boolean bool) boolean type data converts a String '' true 'or' false 'and return

BooleanUtils.toStringTrueFalse(true) = "true"
BooleanUtils.toStringTrueFalse(false) = "false"

toStringYesNo (boolean bool) boolean type data converts a String 'yes' or 'no' and return

BooleanUtils.toStringYesNo(true) = "yes"
BooleanUtils.toStringYesNo(false) = "no"

xor(boolean... array) 异或

BooleanUtils.xor(true, true) = false
BooleanUtils.xor(false, false) = false
BooleanUtils.xor(true, false) = true


Four, ClassPathUtils
class path tool

toFullyQualifiedName (Class <?> context, String resourceName) Returns a string from the class package name spliced ​​+ resourceName

ClassPathUtils.toFullyQualifiedName(StringUtils.class, "StringUtils.properties") = "org.apache.commons.lang3.StringUtils.properties"

toFullyQualifiedName (Package context, String resourceName) Returns a string from the class package name spliced ​​+ resourceName

ClassPathUtils.toFullyQualifiedName(StringUtils.class.getPackage(), "StringUtils.properties") = "org.apache.commons.lang3.StringUtils.properties"

toFullyQualifiedPath (Class <?> context, String resourceName) Returns a string from the class package name spliced ​​+ resourceName

ClassPathUtils.toFullyQualifiedPath(StringUtils.class, "StringUtils.properties") = "org/apache/commons/lang3/StringUtils.properties"

toFullyQualifiedPath (Package context, String resourceName) Returns a string from the class package name spliced ​​+ resourceName

ClassPathUtils.toFullyQualifiedPath(StringUtils.class, "StringUtils.properties") = "org/apache/commons/lang3/StringUtils.properties"

 


Five, EnumUtils
enumeration tools

getEnum (Class <E> enumClass, String enumName) through class returns an enumeration, may return empty

getEnumList (Class <E> enumClass) by returning a class enumerations

getEnumMap (Class <E> enumClass) by enumeration class returns a map

isValidEnum (Class <E> enumClass, String enumName) enumName verify whether in the enumeration, returns true false

Guess you like

Origin www.cnblogs.com/deityjian/p/11448277.html