Java Code Examples for org.drools.core.util.StringUtils#isEmpty()
The following examples show how to use
org.drools.core.util.StringUtils#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectiveDescr.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public void buildExpression(StringBuilder sb ) { if ( !StringUtils.isEmpty( prefix )) { sb.append( prefix ); sb.append( " " ); } for ( int i = 0; i < this.children.size(); i++ ) { if ( isParen() && children.get( i ) instanceof ConnectiveDescr ) { sb.append( "(" ); ((ConnectiveDescr)children.get( i ) ).buildExpression( sb ); sb.append( ")" ); } else { sb.append( children.get( i ) ); } if ( i < this.children.size() -1 ) { sb.append( " " ); sb.append( connective ); sb.append( " " ); } } }
Example 2
Source File: InsertObjectCommand.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public FactHandle execute(Context context) { KieSession ksession = ((RegistryContext)context).lookup( KieSession.class ); FactHandle factHandle; if ( StringUtils.isEmpty( this.entryPoint ) ) { factHandle = ksession.insert( object ); } else { factHandle = ksession.getEntryPoint( this.entryPoint ).insert( object ); } if ( outIdentifier != null ) { if ( this.returnObject ) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, object ); } ((RegistryContext) context).lookup( ExecutionResultImpl.class ).getFactHandles().put( this.outIdentifier, factHandle ); } if ( disconnected ) { DefaultFactHandle disconnectedHandle = ((DefaultFactHandle)factHandle).clone(); disconnectedHandle.disconnect(); return disconnectedHandle; } return factHandle; }
Example 3
Source File: SessionConfiguration.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public final void setProperty(String name, String value) { name = name.trim(); if ( StringUtils.isEmpty( name ) ) { return; } if ( name.equals( KeepReferenceOption.PROPERTY_NAME ) ) { setKeepReference(StringUtils.isEmpty(value) || Boolean.parseBoolean(value)); } else if ( name.equals( ForceEagerActivationOption.PROPERTY_NAME ) ) { setForceEagerActivationFilter(ForceEagerActivationOption.resolve(StringUtils.isEmpty(value) ? "false" : value).getFilter()); } else if ( name.equals( TimedRuleExecutionOption.PROPERTY_NAME ) ) { setTimedRuleExecutionFilter(TimedRuleExecutionOption.resolve(StringUtils.isEmpty(value) ? "false" : value).getFilter()); } else if ( name.equals( ClockTypeOption.PROPERTY_NAME ) ) { setClockType(ClockType.resolveClockType(StringUtils.isEmpty(value) ? "realtime" : value)); } else if ( name.equals( TimerJobFactoryOption.PROPERTY_NAME ) ) { setTimerJobFactoryType(TimerJobFactoryType.resolveTimerJobFactoryType(StringUtils.isEmpty(value) ? "default" : value)); } else if ( name.equals( QueryListenerOption.PROPERTY_NAME ) ) { String property = StringUtils.isEmpty(value) ? QueryListenerOption.STANDARD.getAsString() : value; setQueryListenerOption( QueryListenerOption.determineQueryListenerClassOption( property ) ); } else if ( name.equals( BeliefSystemTypeOption.PROPERTY_NAME ) ) { setBeliefSystemType(StringUtils.isEmpty(value) ? BeliefSystemType.SIMPLE : BeliefSystemType.resolveBeliefSystemType(value)); } }
Example 4
Source File: MemoryFolder.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public Folder getParent() { if ( pFolder == null ) { String p = trimLeadingAndTrailing( path ); if ( p.indexOf( '/' ) == -1 ) { pFolder = new MemoryFolder( mfs, "" ); } else { String[] elements = p.split( "/" ); String newPath = ""; boolean first = true; for ( int i = 0; i < elements.length - 1; i++ ) { if ( !StringUtils.isEmpty( elements[i] ) ) { if ( !first ) { newPath = newPath + "/"; } newPath = newPath + elements[i]; first = false; } } pFolder = new MemoryFolder( mfs, newPath ); } } return pFolder; }
Example 5
Source File: RulesManager.java From hacep with Apache License 2.0 | 5 votes |
public void start(String groupId, String artifactId, String version) { if (started.compareAndSet(false, true)) { kieServices = KieServices.Factory.get(); if (!(StringUtils.isEmpty(groupId) || StringUtils.isEmpty(artifactId) || StringUtils.isEmpty(version)) && (!rulesConfiguration.getGroupId().equals(groupId) || !rulesConfiguration.getArtifactId().equals(artifactId))) { throw new IllegalStateException(String.format("Cannot start a Rule Manager with different Group Id and Artifact. " + "Rule configuration releaseId [%s:%s:%s] cached value [%s:%s:%s]", rulesConfiguration.getGroupId(), rulesConfiguration.getArtifactId(), rulesConfiguration.getVersion(), groupId, artifactId, version)); } this.kieContainer = newKieContainer(version); this.releaseId = this.kieContainer.getReleaseId(); } }
Example 6
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public Long getDefaultValueAsLong( ) { try { return initExpr == null ? 0L : Long.parseLong(initExpr); } catch (NumberFormatException nfe) { return StringUtils.isEmpty( initExpr ) ? 0L : MVELSafeHelper.getEvaluator().eval( initExpr, Long.class ); } }
Example 7
Source File: RulesManager.java From hacep with Apache License 2.0 | 5 votes |
public KieSession newKieSession(KieContainer kieContainer) { checkStatus(); if (!StringUtils.isEmpty(rulesConfiguration.getKieSessionName())) { return kieContainer.newKieSession(rulesConfiguration.getKieSessionName()); } return kieContainer.newKieSession(); }
Example 8
Source File: ObjectMarshallingStrategyStoreImpl.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public ObjectMarshallingStrategy getStrategyObject(String strategyName) { if( StringUtils.isEmpty(strategyName) ) { return null; } if (strategyName.startsWith("org.drools.marshalling.impl")) { strategyName = strategyName.replaceFirst("org.drools.marshalling.impl", "org.drools.core.marshalling.impl"); } for( int i = 0; i < this.strategiesList.length; ++i ) { if( strategiesList[i].getName().equals(strategyName) ) { return strategiesList[i]; } } throw new RuntimeException( "Unable to find PlaceholderResolverStrategy for name : " + strategyName ); }
Example 9
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public float getDefaultValueAs_float() { try { return initExpr == null ? 0.0f : Float.parseFloat(initExpr); } catch (NumberFormatException nfe) { return StringUtils.isEmpty( initExpr ) ? 0.0f : MVELSafeHelper.getEvaluator().eval( initExpr, Float.class ); } }
Example 10
Source File: RulesManager.java From hacep with Apache License 2.0 | 5 votes |
public KieBase getKieBase(KieContainer kieContainer) { checkStatus(); if (!StringUtils.isEmpty(rulesConfiguration.getKieBaseName())) { return kieContainer.getKieBase(rulesConfiguration.getKieBaseName()); } return kieContainer.getKieBase(); }
Example 11
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public byte getDefaultValueAs_byte() { try { return initExpr == null ? 0 : Byte.parseByte(initExpr); } catch (NumberFormatException nfe) { return StringUtils.isEmpty( initExpr ) ? 0 : MVELSafeHelper.getEvaluator().eval( initExpr, Byte.class ); } }
Example 12
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public Character getDefaultValueAsChar() { if ( StringUtils.isEmpty( initExpr ) ) { return '\u0000'; } else { if ( initExpr.length() == 1 ) { return initExpr.charAt(0); } else { return MVELSafeHelper.getEvaluator().eval( initExpr, Character.class ); } } }
Example 13
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public short getDefaultValueAs_short() { try { return initExpr == null ? 0 : Short.parseShort(initExpr); } catch (NumberFormatException nfe) { return StringUtils.isEmpty( initExpr ) ? 0 : MVELSafeHelper.getEvaluator().eval( initExpr, Short.class ); } }
Example 14
Source File: KnowledgeBuilderImpl.java From kogito-runtimes with Apache License 2.0 | 5 votes |
protected void initPackageRegistries(Collection<CompositePackageDescr> packages) { for ( CompositePackageDescr packageDescr : packages ) { if ( StringUtils.isEmpty(packageDescr.getName()) ) { packageDescr.setName( getBuilderConfiguration().getDefaultPackageName() ); } getOrCreatePackageRegistry( packageDescr ); } }
Example 15
Source File: ReleaseIdImpl.java From kogito-runtimes with Apache License 2.0 | 5 votes |
private static ReleaseId getReleaseIdFromProperties( Properties props, String path ) { String groupId = props.getProperty("groupId"); String artifactId = props.getProperty("artifactId"); String version = props.getProperty("version"); if (StringUtils.isEmpty(groupId) || StringUtils.isEmpty(artifactId) || StringUtils.isEmpty(version)) { throw new RuntimeException("pom.properties exists but ReleaseId content is malformed\n" + path); } return new ReleaseIdImpl( groupId, artifactId, version); }
Example 16
Source File: FieldDefinition.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public double getDefaultValueAs_double() { try { return initExpr == null ? 0.0 : Double.parseDouble(initExpr); } catch (NumberFormatException nfe) { return StringUtils.isEmpty( initExpr ) ? 0.0 : MVELSafeHelper.getEvaluator().eval( initExpr, Double.class ); } }
Example 17
Source File: RuleBaseConfiguration.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public void setProperty(String name, String value) { name = name.trim(); if (StringUtils.isEmpty(name)) { return; } if (name.equals(SequentialAgendaOption.PROPERTY_NAME)) { setSequentialAgenda(SequentialAgenda.determineSequentialAgenda(StringUtils.isEmpty(value) ? "sequential" : value)); } else if (name.equals(SequentialOption.PROPERTY_NAME)) { setSequential(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value)); } else if (name.equals(RemoveIdentitiesOption.PROPERTY_NAME)) { setRemoveIdentities(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value)); } else if (name.equals(ShareAlphaNodesOption.PROPERTY_NAME)) { setShareAlphaNodes(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value)); } else if ( name.equals( ShareBetaNodesOption.PROPERTY_NAME ) ) { setShareBetaNodes(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value)); } else if ( name.equals( PermGenThresholdOption.PROPERTY_NAME ) ) { setPermGenThreshold(StringUtils.isEmpty(value) ? PermGenThresholdOption.DEFAULT_VALUE : Integer.parseInt(value)); } else if ( name.equals( ConstraintJittingThresholdOption.PROPERTY_NAME ) ) { setJittingThreshold( StringUtils.isEmpty( value ) ? ConstraintJittingThresholdOption.DEFAULT_VALUE : Integer.parseInt( value ) ); } else if ( name.equals( AlphaThresholdOption.PROPERTY_NAME ) ) { setAlphaNodeHashingThreshold( StringUtils.isEmpty( value ) ? 3 : Integer.parseInt(value)); } else if ( name.equals( SessionsPoolOption.PROPERTY_NAME ) ) { setSessionPoolSize( StringUtils.isEmpty( value ) ? -1 : Integer.parseInt(value)); } else if ( name.equals( CompositeKeyDepthOption.PROPERTY_NAME ) ) { setCompositeKeyDepth( StringUtils.isEmpty( value ) ? 3 : Integer.parseInt(value)); } else if ( name.equals( IndexLeftBetaMemoryOption.PROPERTY_NAME ) ) { setIndexLeftBetaMemory( StringUtils.isEmpty( value ) ? true : Boolean.valueOf(value)); } else if ( name.equals( IndexRightBetaMemoryOption.PROPERTY_NAME ) ) { setIndexRightBetaMemory( StringUtils.isEmpty( value ) ? true : Boolean.valueOf(value)); } else if ( name.equals( IndexPrecedenceOption.PROPERTY_NAME ) ) { setIndexPrecedenceOption( StringUtils.isEmpty( value ) ? IndexPrecedenceOption.EQUALITY_PRIORITY : IndexPrecedenceOption.determineIndexPrecedence(value)); } else if ( name.equals( EqualityBehaviorOption.PROPERTY_NAME ) ) { setAssertBehaviour( AssertBehaviour.determineAssertBehaviour( StringUtils.isEmpty( value ) ? "identity" : value)); } else if ( name.equals( ConsequenceExceptionHandlerOption.PROPERTY_NAME ) ) { setConsequenceExceptionHandler( StringUtils.isEmpty( value ) ? DefaultConsequenceExceptionHandler.class.getName() : value); } else if ( name.equals( "drools.ruleBaseUpdateHandler" ) ) { setRuleBaseUpdateHandler( StringUtils.isEmpty( value ) ? "" : value); } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) { setAdvancedProcessRuleIntegration( StringUtils.isEmpty( value ) ? false : Boolean.valueOf(value)); } else if ( name.equals( MultithreadEvaluationOption.PROPERTY_NAME ) ) { setMultithreadEvaluation( StringUtils.isEmpty( value ) ? false : Boolean.valueOf(value)); } else if ( name.equals( MaxThreadsOption.PROPERTY_NAME ) ) { setMaxThreads( StringUtils.isEmpty( value ) ? 3 : Integer.parseInt(value)); } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) { setEventProcessingMode( EventProcessingOption.determineEventProcessingMode( StringUtils.isEmpty( value ) ? "cloud" : value)); } else if ( name.equals( MBeansOption.PROPERTY_NAME ) ) { setMBeansEnabled( MBeansOption.isEnabled(value)); } else if ( name.equals( ClassLoaderCacheOption.PROPERTY_NAME ) ) { setClassLoaderCacheEnabled( StringUtils.isEmpty( value ) ? true : Boolean.valueOf(value)); } }
Example 18
Source File: RuleBaseConfiguration.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public String getProperty(String name) { name = name.trim(); if ( StringUtils.isEmpty( name ) ) { return null; } if ( name.equals( SequentialAgendaOption.PROPERTY_NAME ) ) { return getSequentialAgenda().toExternalForm(); } else if ( name.equals( SequentialOption.PROPERTY_NAME ) ) { return Boolean.toString( isSequential() ); } else if ( name.equals( RemoveIdentitiesOption.PROPERTY_NAME ) ) { return Boolean.toString( isRemoveIdentities() ); } else if ( name.equals( ShareAlphaNodesOption.PROPERTY_NAME ) ) { return Boolean.toString( isShareAlphaNodes() ); } else if ( name.equals( ShareBetaNodesOption.PROPERTY_NAME ) ) { return Boolean.toString( isShareBetaNodes() ); } else if ( name.equals( PermGenThresholdOption.PROPERTY_NAME ) ) { return Integer.toString( getPermGenThreshold() ); } else if ( name.equals( ConstraintJittingThresholdOption.PROPERTY_NAME ) ) { return Integer.toString( getJittingThreshold() ); } else if ( name.equals( AlphaThresholdOption.PROPERTY_NAME ) ) { return Integer.toString( getAlphaNodeHashingThreshold() ); } else if ( name.equals( SessionsPoolOption.PROPERTY_NAME ) ) { return Integer.toString( getSessionPoolSize() ); } else if ( name.equals( CompositeKeyDepthOption.PROPERTY_NAME ) ) { return Integer.toString( getCompositeKeyDepth() ); } else if ( name.equals( IndexLeftBetaMemoryOption.PROPERTY_NAME ) ) { return Boolean.toString( isIndexLeftBetaMemory() ); } else if ( name.equals( IndexRightBetaMemoryOption.PROPERTY_NAME ) ) { return Boolean.toString( isIndexRightBetaMemory()); } else if ( name.equals( IndexPrecedenceOption.PROPERTY_NAME ) ) { return getIndexPrecedenceOption().getValue(); } else if ( name.equals( EqualityBehaviorOption.PROPERTY_NAME ) ) { return getAssertBehaviour().toExternalForm(); } else if ( name.equals( ConsequenceExceptionHandlerOption.PROPERTY_NAME ) ) { return getConsequenceExceptionHandler(); } else if ( name.equals( "drools.ruleBaseUpdateHandler" ) ) { return getRuleBaseUpdateHandler(); } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) { return Boolean.toString(isAdvancedProcessRuleIntegration()); } else if ( name.equals( MultithreadEvaluationOption.PROPERTY_NAME ) ) { return Boolean.toString( isMultithreadEvaluation() ); } else if ( name.equals( MaxThreadsOption.PROPERTY_NAME ) ) { return Integer.toString( getMaxThreads()); } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) { return getEventProcessingMode().getMode(); } else if ( name.equals( MBeansOption.PROPERTY_NAME ) ) { return isMBeansEnabled() ? "enabled" : "disabled"; } else if ( name.equals( ClassLoaderCacheOption.PROPERTY_NAME ) ) { return Boolean.toString( isClassLoaderCacheEnabled() ); } return null; }
Example 19
Source File: TypeDeclarationUtils.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public static boolean isQualified(String name) { return !StringUtils.isEmpty(name) && name.indexOf('.') >= 0; }
Example 20
Source File: NodeValidator.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public NodeValidator notEmpty(String name, String value) { if (StringUtils.isEmpty(value)) { this.errors.add(MessageFormat.format("{0} should not be empty", name)); } return this; }