本文整理汇总了Java中org.apache.commons.lang.BooleanUtils类的典型用法代码示例。如果您正苦于以下问题:Java BooleanUtils类的具体用法?Java BooleanUtils怎么用?Java BooleanUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BooleanUtils类属于org.apache.commons.lang包,在下文中一共展示了BooleanUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toBoolean
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
/**
* Convert the specified object into a Boolean. Internally the
* {@code org.apache.commons.lang.BooleanUtils} class from the <a
* href="http://commons.apache.org/lang/">Commons Lang</a> project is used
* to perform this conversion. This class accepts some more tokens for the
* boolean value of <b>true</b>, e.g. {@code yes} and {@code on}. Please
* refer to the documentation of this class for more details.
*
* @param value the value to convert
* @return the converted value
* @throws ConversionException thrown if the value cannot be converted to a boolean
*/
public static Boolean toBoolean(Object value) throws ConversionException {
if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof String) {
Boolean b = BooleanUtils.toBooleanObject((String) value);
if (b == null) {
throw new ConversionException("The value " + value
+ " can't be converted to a Boolean object");
}
return b;
} else {
throw new ConversionException("The value " + value
+ " can't be converted to a Boolean object");
}
}
示例2: createHierarhicalRow
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
protected int createHierarhicalRow(TreeTable table, List<Table.Column> columns,
Boolean exportExpanded, int rowNumber, Object itemId) {
HierarchicalDatasource hd = table.getDatasource();
createRow(table, columns, 0, ++rowNumber, itemId);
if (BooleanUtils.isTrue(exportExpanded) && !table.isExpanded(itemId) && !hd.getChildren(itemId).isEmpty()) {
return rowNumber;
} else {
final Collection children = hd.getChildren(itemId);
if (children != null && !children.isEmpty()) {
for (Object id : children) {
if (BooleanUtils.isTrue(exportExpanded) && !table.isExpanded(id) && !hd.getChildren(id).isEmpty()) {
createRow(table, columns, 0, ++rowNumber, id);
continue;
}
rowNumber = createHierarhicalRow(table, columns, exportExpanded, rowNumber, id);
}
}
}
return rowNumber;
}
示例3: printActiveScheduledTasks
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
@Override
public String printActiveScheduledTasks() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
StringBuilder sb = new StringBuilder();
List<ScheduledTask> tasks = scheduling.getActiveTasks();
for (ScheduledTask task : tasks) {
sb.append(task).append(", lastStart=");
if (task.getLastStartTime() != null) {
sb.append(dateFormat.format(task.getLastStartTime()));
if (BooleanUtils.isTrue(task.getSingleton()))
sb.append(" on ").append(task.getLastStartServer());
} else {
sb.append("<never>");
}
sb.append("\n");
}
return sb.toString();
}
示例4: addNewProposedShadow
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
public String addNewProposedShadow(ProvisioningContext ctx, PrismObject<ShadowType> shadow, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, SecurityViolationException {
ResourceConsistencyType consistency = ctx.getResource().getConsistency();
if (consistency == null) {
return null;
}
if (!BooleanUtils.isTrue(consistency.isUseProposedShadows())) {
return null;
}
PrismObject<ShadowType> repoShadow = createRepositoryShadow(ctx, shadow);
repoShadow.asObjectable().setLifecycleState(SchemaConstants.LIFECYCLE_PROPOSED);
addPendingOperationAdd(repoShadow, shadow, task.getTaskIdentifier());
ConstraintsChecker.onShadowAddOperation(repoShadow.asObjectable());
String oid = repositoryService.addObject(repoShadow, null, result);
LOGGER.trace("Draft shadow added to the repository: {}", repoShadow);
return oid;
}
示例5: matchesOrgRelation
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
private <O extends ObjectType> boolean matchesOrgRelation(PrismObject<O> object, ObjectReferenceType subjectParentOrgRef,
OrgRelationObjectSpecificationType specOrgRelation, String autzHumanReadableDesc, String desc) throws SchemaException {
if (!MiscSchemaUtil.compareRelation(specOrgRelation.getSubjectRelation(), subjectParentOrgRef.getRelation())) {
return false;
}
if (BooleanUtils.isTrue(specOrgRelation.isIncludeReferenceOrg()) && subjectParentOrgRef.getOid().equals(object.getOid())) {
return true;
}
if (specOrgRelation.getScope() == null) {
return repositoryService.isDescendant(object, subjectParentOrgRef.getOid());
}
switch (specOrgRelation.getScope()) {
case ALL_DESCENDANTS:
return repositoryService.isDescendant(object, subjectParentOrgRef.getOid());
case DIRECT_DESCENDANTS:
return hasParentOrgRef(object, subjectParentOrgRef.getOid());
case ALL_ANCESTORS:
return repositoryService.isAncestor(object, subjectParentOrgRef.getOid());
default:
throw new UnsupportedOperationException("Unknown orgRelation scope "+specOrgRelation.getScope());
}
}
示例6: getDynamicAttributeDifference
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
protected EntityPropertyDiff getDynamicAttributeDifference(Object firstValue,
Object secondValue,
MetaProperty metaProperty,
CategoryAttribute categoryAttribute) {
Range range = metaProperty.getRange();
if (range.isDatatype() || range.isEnum()) {
if (!Objects.equals(firstValue, secondValue)) {
return new EntityBasicPropertyDiff(firstValue, secondValue, metaProperty);
}
} else if (range.isClass()) {
if (BooleanUtils.isTrue(categoryAttribute.getIsCollection())) {
return getDynamicAttributeCollectionDiff(firstValue, secondValue, metaProperty);
} else {
if (!Objects.equals(firstValue, secondValue)) {
return new EntityClassPropertyDiff(firstValue, secondValue, metaProperty);
}
}
}
return null;
}
示例7: convertToStr
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
/**
* Convert the provides object to a string representation.
*
* @param value
* @return String representation of value
*/
default String convertToStr(Object value) {
if (value instanceof String[]) {
String stringVal = "";
String[] values = (String[]) value;
for (int i = 0; i < values.length; i++) {
stringVal += values[i];
if (i != values.length - 1) {
stringVal += ',';
}
}
return stringVal;
} else if (value instanceof Integer) {
return Integer.toString((int) value);
} else if (value instanceof Boolean) {
return BooleanUtils.toStringTrueFalse((Boolean) value);
} else {
return value.toString();
}
}
示例8: setupDatabase
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
/**
* Drop and recreates the databaseName from the template files.
*
* @param skipDatabaseCreation
* If set to true, the databaseName creation will be skipped (Default: false).
*
* @throws Exception
* Exception.
*/
@Parameters({ "skipDatabaseCreation" })
@BeforeClass(dependsOnMethods = { "setupIntegrationTest" }, groups = GROUP_INTEGRATION_TEST_SETUP)
public void setupDatabase(@Optional("false") String skipDatabaseCreation) throws Exception {
if (BooleanUtils.toBoolean(skipDatabaseCreation)) {
return;
}
LOGGER.info("Using the following JDBC URL for the test database: " + jdbcURL);
try {
DatabaseUtils.recreateDatabase(jdbcTempURL, suUsername, suPassword, databaseName,
databaseType, username);
initializeDatabaseSchemaAndContent();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
throw e;
}
}
示例9: evaluateScriptCondition
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
private boolean evaluateScriptCondition(OperationProvisioningScriptType script,
ExpressionVariables variables, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
ExpressionType condition = script.getCondition();
if (condition == null) {
return true;
}
PrismPropertyValue<Boolean> conditionOutput = ExpressionUtil.evaluateCondition(variables, condition, expressionFactory, " condition for provisioning script ", task, result);
if (conditionOutput == null) {
return true;
}
Boolean conditionOutputValue = conditionOutput.getValue();
return BooleanUtils.isNotFalse(conditionOutputValue);
}
示例10: getFilterCaption
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
protected String getFilterCaption(FilterEntity filterEntity) {
String name;
if (filterEntity != null) {
if (filterEntity.getCode() == null)
name = InstanceUtils.getInstanceName(filterEntity);
else {
name = messages.getMainMessage(filterEntity.getCode());
}
AbstractSearchFolder folder = filterEntity.getFolder();
if (folder != null) {
if (!StringUtils.isBlank(folder.getTabName()))
name = messages.getMainMessage(folder.getTabName());
else if (!StringUtils.isBlank(folder.getName())) {
name = messages.getMainMessage(folder.getName());
}
if (BooleanUtils.isTrue(filterEntity.getIsSet()))
name = getMainMessage("filter.setPrefix") + " " + name;
else
name = getMainMessage("filter.folderPrefix") + " " + name;
}
} else
name = "";
return name;
}
示例11: extractWorkItemResult
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
@Override
public WorkItemResultType extractWorkItemResult(Map<String, Object> variables) {
Boolean wasCompleted = ActivitiUtil.getVariable(variables, VARIABLE_WORK_ITEM_WAS_COMPLETED, Boolean.class, prismContext);
if (BooleanUtils.isNotTrue(wasCompleted)) {
return null;
}
WorkItemResultType result = new WorkItemResultType(prismContext);
result.setOutcome(ActivitiUtil.getVariable(variables, FORM_FIELD_OUTCOME, String.class, prismContext));
result.setComment(ActivitiUtil.getVariable(variables, FORM_FIELD_COMMENT, String.class, prismContext));
String additionalDeltaString = ActivitiUtil.getVariable(variables, FORM_FIELD_ADDITIONAL_DELTA, String.class, prismContext);
boolean isApproved = ApprovalUtils.isApproved(result);
if (isApproved && StringUtils.isNotEmpty(additionalDeltaString)) {
try {
ObjectDeltaType additionalDelta = prismContext.parserFor(additionalDeltaString).parseRealValue(ObjectDeltaType.class);
ObjectTreeDeltasType treeDeltas = new ObjectTreeDeltasType();
treeDeltas.setFocusPrimaryDelta(additionalDelta);
result.setAdditionalDeltas(treeDeltas);
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't parse delta received from the activiti form:\n{}", e, additionalDeltaString);
throw new SystemException("Couldn't parse delta received from the activiti form: " + e.getMessage(), e);
}
}
return result;
}
示例12: init
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
@Override
public void init(Map<String, Object> params) {
@SuppressWarnings("unchecked")
BackgroundTask<T, V> task = (BackgroundTask<T, V>) params.get("task");
String title = (String) params.get("title");
if (title != null) {
setCaption(title);
}
String message = (String) params.get("message");
if (message != null) {
text.setValue(message);
}
Boolean cancelAllowedNullable = (Boolean) params.get("cancelAllowed");
cancelAllowed = BooleanUtils.isTrue(cancelAllowedNullable);
cancelButton.setVisible(cancelAllowed);
getDialogOptions().setCloseable(cancelAllowed);
BackgroundTask<T, V> wrapperTask = new LocalizedTaskWrapper<>(task, this);
taskHandler = backgroundWorker.handle(wrapperTask);
taskHandler.execute();
}
示例13: getAllAttributes
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
protected Set<String> getAllAttributes(Entity entity) {
if (entity == null) {
return null;
}
Set<String> attributes = new HashSet<>();
MetaClass metaClass = metadata.getClassNN(entity.getClass());
for (MetaProperty metaProperty : metaClass.getProperties()) {
Range range = metaProperty.getRange();
if (range.isClass() && range.getCardinality().isMany()) {
continue;
}
attributes.add(metaProperty.getName());
}
Collection<CategoryAttribute> categoryAttributes = dynamicAttributes.getAttributesForMetaClass(metaClass);
if (categoryAttributes != null) {
for (CategoryAttribute categoryAttribute : categoryAttributes) {
if (BooleanUtils.isNotTrue(categoryAttribute.getIsCollection())) {
attributes.add(
DynamicAttributesUtils.getMetaPropertyPath(metaClass, categoryAttribute).getMetaProperty().getName());
}
}
}
return attributes;
}
示例14: checkAuditEnabled
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
private void checkAuditEnabled(SystemConfigurationType configurationType) throws FaultMessage {
LoggingConfigurationType loggingConfig = configurationType.getLogging();
AuditingConfigurationType auditConfig = loggingConfig.getAuditing();
if (auditConfig == null) {
auditConfig = new AuditingConfigurationType();
auditConfig.setEnabled(true);
loggingConfig.setAuditing(auditConfig);
} else {
if (BooleanUtils.isTrue(auditConfig.isEnabled())) {
return;
}
auditConfig.setEnabled(true);
}
ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class,
SystemObjectsType.SYSTEM_CONFIGURATION.value(), "logging", ModificationTypeType.REPLACE, loggingConfig);
ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
assertSuccess(deltaOpList);
}
示例15: init
import org.apache.commons.lang.BooleanUtils; //导入依赖的package包/类
@Override
public void init(Map<String, Object> params) {
customerTable.setStyleProvider((entity, property) -> {
if (property == null) {
if (BooleanUtils.isTrue(entity.getActive())) {
return "active-customer";
}
} else if (property.equals("grade")) {
switch (entity.getGrade()) {
case PREMIUM:
return "premium-grade";
case HIGH:
return "high-grade";
case STANDARD:
return "standard-grade";
default:
return null;
}
}
return null;
});
}