本文整理匯總了Java中org.apache.commons.lang3.BooleanUtils.toBooleanObject方法的典型用法代碼示例。如果您正苦於以下問題:Java BooleanUtils.toBooleanObject方法的具體用法?Java BooleanUtils.toBooleanObject怎麽用?Java BooleanUtils.toBooleanObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.BooleanUtils
的用法示例。
在下文中一共展示了BooleanUtils.toBooleanObject方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveModifier
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
private void resolveModifier(
final GenericAttributeValue<Boolean> attribute,
final String methodName,
final List<String> resultList
) {
if (attribute == null) {
return;
}
final Boolean value = BooleanUtils.toBooleanObject(attribute.getStringValue());
if (value == null) {
return;
}
if (value) {
resultList.add(methodName);
} else {
resultList.add(methodName + "(false)");
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:20,代碼來源:TSStructureTreeElement.java
示例2: createBooleanExpression
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
/**
* Return an expression for {@code entityPath.fieldName} (for Booleans) with
* the {@code operator} or "equal" by default.
* <p/>
* Expr: {@code entityPath.fieldName eq searchObj}
*
* @param entityPath
* @param fieldName
* @param searchObj
* @param operator
* @return
*/
public static <T> BooleanExpression createBooleanExpression(
PathBuilder<T> entityPath, String fieldName, Object searchObj,
String operator) {
Boolean value = BooleanUtils.toBooleanObject((String) searchObj);
if (value != null) {
if (StringUtils.equalsIgnoreCase(operator, OPERATOR_GOE)) {
return entityPath.getBoolean(fieldName).goe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "gt")) {
return entityPath.getBoolean(fieldName).gt(value);
}
else if (StringUtils.equalsIgnoreCase(operator, OPERATOR_LOE)) {
return entityPath.getBoolean(fieldName).loe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "lt")) {
return entityPath.getBoolean(fieldName).lt(value);
}
}
return entityPath.get(fieldName).eq(searchObj);
}
示例3: createBooleanExpression
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public <T> BooleanExpression createBooleanExpression(
PathBuilder<T> entityPath, String fieldName, Object searchObj,
String operator) {
Boolean value = BooleanUtils.toBooleanObject((String) searchObj);
if (value != null) {
if (StringUtils.equalsIgnoreCase(operator, OPERATOR_GOE)) {
return entityPath.getBoolean(fieldName).goe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "gt")) {
return entityPath.getBoolean(fieldName).gt(value);
}
else if (StringUtils.equalsIgnoreCase(operator, OPERATOR_LOE)) {
return entityPath.getBoolean(fieldName).loe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "lt")) {
return entityPath.getBoolean(fieldName).lt(value);
}
}
return entityPath.get(fieldName).eq(searchObj);
}
示例4: call
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
@Override
public Object call(Element element, List<SyntaxNode> params) {
if (element == null) {
return false;
}
Object ret = params.get(0).calc(element);
if (ret == null) {
return false;
}
if (ret instanceof Number) {
int i = ((Number) ret).intValue();
return XpathUtil.getElIndexInSameTags(element) == i;
}
if (ret instanceof Boolean) {
return ret;
}
if (ret instanceof CharSequence) {
String s = ret.toString();
Boolean booleanValue = BooleanUtils.toBooleanObject(s);
if (booleanValue != null) {
return booleanValue;
}
return StringUtils.isNotBlank(s);
}
log.warn("can not recognize predicate expression calc result:" + ret);
return false;
}
示例5: convertKeys
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
public Object convertKeys(String key) {
if (BooleanUtils.toBooleanObject(key) != null) {
return BooleanUtils.toBoolean(key);
} else if (NumberUtils.isNumber(key) && (key.contains(",") || key.contains("."))) {
return NumberUtils.toFloat(key);
} else if (NumberUtils.isNumber(key)) {
return NumberUtils.toInt(key);
} else {
return key;
}
}
示例6: parseGeneralString
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
/**
* 支持true/false,on/off, y/n, yes/no的轉換, str為空或無法分析時返回null
*/
public static Boolean parseGeneralString(String str) {
return BooleanUtils.toBooleanObject(str);
}
示例7: getBooleanProperty
import org.apache.commons.lang3.BooleanUtils; //導入方法依賴的package包/類
/**
* Looks up the boolean property associated to the provided key. The following rules are used to determine
* what is returned or if an error will be thrown.
*
* 1) If the key doesn't exist or the value associated to the key is not a valid boolean value (true/false, yes/no, on/off) and the provided default value is NULL then an error will be thrown
* 2) Same as 1 but if the default value is not null then the default value will be returned
* 3) Property key exists and is associated to a valid boolean value then it will be returned regardless of what default value is set to
*
* @param propertyKey
* @param defaultVal
* @return true or false depending on the rules listed above
* @throws CandlestackPropertiesException
* if GlobalCandlestackProperties have not been initialized and if rule 1 applies
*/
public static boolean getBooleanProperty( String propertyKey, Boolean defaultVal ) throws CandlestackPropertiesException {
initCheck();
Boolean val = BooleanUtils.toBooleanObject( globalProps.getProperty( propertyKey ) );
if ( val == null && defaultVal == null ) {
throw new CandlestackPropertiesException( "GlobalCandlestackProperties was unable to locate valid boolean property for property key [" + propertyKey + "]" );
} else if ( val == null ) {
val = defaultVal;
}
return val.booleanValue();
}