Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pibizza committed Jun 27, 2023
1 parent 8cbbe87 commit 294c849
Showing 1 changed file with 32 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ public class RuleSessionConfiguration extends BaseConfiguration<KieSessionOption

private DirectFiringOption directFiringOption;

private QueryListenerOption queryListener;
private QueryListenerOption queryListenerOption;

private ThreadSafeOption threadSafeOption;

private TimedRuleExecutionOption timedRuleExecutionOption;

public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
out.writeObject( queryListener );
out.writeObject( queryListenerOption );
}

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
queryListener = (QueryListenerOption) in.readObject();
queryListenerOption = (QueryListenerOption) in.readObject();
}

public final boolean hasForceEagerActivationFilter() {
Expand All @@ -84,19 +84,19 @@ public RuleSessionConfiguration(CompositeConfiguration<KieSessionOption, SingleV
}

private void init() {
setDirectFiringOption(DirectFiringOption.resolve(getPropertyValue(DirectFiringOption.PROPERTY_NAME, "false")));
setAccumulateNullPropagation(AccumulateNullPropagationOption.resolve(getPropertyValue(AccumulateNullPropagationOption.PROPERTY_NAME, "false")));

setThreadSafeOption(ThreadSafeOption.resolve(getPropertyValue(ThreadSafeOption.PROPERTY_NAME, "true")));
setBeliefSystemType(BeliefSystemType.resolveBeliefSystemType( getPropertyValue( BeliefSystemTypeOption.PROPERTY_NAME, BeliefSystemType.SIMPLE.getId() ) ) );

setAccumulateNullPropagation(AccumulateNullPropagationOption.resolve(getPropertyValue(AccumulateNullPropagationOption.PROPERTY_NAME, "false")));
setDirectFiringOption(DirectFiringOption.resolve(getPropertyValue(DirectFiringOption.PROPERTY_NAME, "false")));

setForceEagerActivationFilter(ForceEagerActivationOption.resolve( getPropertyValue( ForceEagerActivationOption.PROPERTY_NAME, "false" ) ).getFilter());

setTimedRuleExecutionFilter(TimedRuleExecutionOption.resolve( getPropertyValue( TimedRuleExecutionOption.PROPERTY_NAME, "false" ) ));
setQueryListenerOption(QueryListenerOption.determineQueryListenerClassOption( getPropertyValue( QueryListenerOption.PROPERTY_NAME, QueryListenerOption.STANDARD.getAsString() ) ) );

setBeliefSystemType( BeliefSystemType.resolveBeliefSystemType( getPropertyValue( BeliefSystemTypeOption.PROPERTY_NAME, BeliefSystemType.SIMPLE.getId() ) ) );
setThreadSafeOption(ThreadSafeOption.resolve(getPropertyValue(ThreadSafeOption.PROPERTY_NAME, "true")));

setQueryListenerOption( QueryListenerOption.determineQueryListenerClassOption( getPropertyValue( QueryListenerOption.PROPERTY_NAME, QueryListenerOption.STANDARD.getAsString() ) ) );
setTimedRuleExecutionFilter(TimedRuleExecutionOption.resolve( getPropertyValue( TimedRuleExecutionOption.PROPERTY_NAME, "false" ) ));
}

private void setDirectFiringOption(DirectFiringOption directFiringOption) {
Expand All @@ -115,18 +115,14 @@ private void setAccumulateNullPropagation(AccumulateNullPropagationOption accumu

private void setQueryListenerOption( QueryListenerOption queryListener ) {
checkCanChange();
this.queryListener = queryListener;
this.queryListenerOption = queryListener;
}

private void setTimedRuleExecutionFilter(TimedRuleExecutionOption timedRuleExecutionOption) {
checkCanChange(); // throws an exception if a change isn't possible;
this.timedRuleExecutionOption = timedRuleExecutionOption;
}

private TimedRuleExecutionOption getTimedRuleExecutionOption() {
return this.timedRuleExecutionOption;
}

private void setForceEagerActivationFilter(ForceEagerActivationFilter forceEagerActivationFilter) {
checkCanChange(); // throws an exception if a change isn't possible;
this.forceEagerActivationFilter = forceEagerActivationFilter;
Expand All @@ -148,32 +144,32 @@ public void setBeliefSystemType(BeliefSystemType beliefSystemType) {

public final <T extends KieSessionOption> void setOption(T option) {
switch (option.propertyName()) {
case DirectFiringOption.PROPERTY_NAME: {
setDirectFiringOption(((DirectFiringOption) option));
break;
}
case ThreadSafeOption.PROPERTY_NAME: {
setThreadSafeOption(((ThreadSafeOption) option));
case AccumulateNullPropagationOption.PROPERTY_NAME: {
setAccumulateNullPropagation(((AccumulateNullPropagationOption) option));
break;
}
case BeliefSystemTypeOption.PROPERTY_NAME: {
setBeliefSystemType(((BeliefSystemType.resolveBeliefSystemType(((BeliefSystemTypeOption) option).getBeliefSystemType()))));
break;
}
case AccumulateNullPropagationOption.PROPERTY_NAME: {
setAccumulateNullPropagation(((AccumulateNullPropagationOption) option));
case DirectFiringOption.PROPERTY_NAME: {
setDirectFiringOption(((DirectFiringOption) option));
break;
}
case ForceEagerActivationOption.PROPERTY_NAME: {
setForceEagerActivationFilter(((ForceEagerActivationOption) option).getFilter());
break;
}
case TimedRuleExecutionOption.PROPERTY_NAME: {
setTimedRuleExecutionFilter(((TimedRuleExecutionOption) option));
break;
}
case QueryListenerOption.PROPERTY_NAME: {
setQueryListenerOption((QueryListenerOption) option);
break;
}
case BeliefSystemTypeOption.PROPERTY_NAME: {
setBeliefSystemType(((BeliefSystemType.resolveBeliefSystemType(((BeliefSystemTypeOption) option).getBeliefSystemType()))));
case ThreadSafeOption.PROPERTY_NAME: {
setThreadSafeOption(((ThreadSafeOption) option));
break;
}
case TimedRuleExecutionOption.PROPERTY_NAME: {
setTimedRuleExecutionFilter(((TimedRuleExecutionOption) option));
break;
}
default:
Expand All @@ -193,20 +189,20 @@ public final <T extends SingleValueKieSessionOption> T getOption(OptionKey<T> op
case AccumulateNullPropagationOption.PROPERTY_NAME: {
return (T) accumulateNullPropagation;
}
case BeliefSystemTypeOption.PROPERTY_NAME: {
return (T) BeliefSystemTypeOption.get( this.getBeliefSystemType().getId() );
}
case DirectFiringOption.PROPERTY_NAME: {
return (T) directFiringOption;
}
case QueryListenerOption.PROPERTY_NAME: {
return (T) queryListenerOption;
}
case ThreadSafeOption.PROPERTY_NAME: {
return (T) threadSafeOption;
}
case TimedRuleExecutionOption.PROPERTY_NAME: {
return (T) getTimedRuleExecutionOption();
}
case QueryListenerOption.PROPERTY_NAME: {
return (T) this.queryListener;
}
case BeliefSystemTypeOption.PROPERTY_NAME: {
return (T) BeliefSystemTypeOption.get( this.getBeliefSystemType().getId() );
return (T) timedRuleExecutionOption;
}
default:
return compConfig.getOption(option);
Expand Down Expand Up @@ -271,7 +267,7 @@ public String getInternalProperty(String name) {
} case AccumulateNullPropagationOption.PROPERTY_NAME: {
return Boolean.toString(accumulateNullPropagation.isAccumulateNullPropagation());
} case QueryListenerOption.PROPERTY_NAME: {
return this.queryListener.getAsString();
return this.queryListenerOption.getAsString();
} case BeliefSystemTypeOption.PROPERTY_NAME: {
return getBeliefSystemType().getId();
}
Expand Down

0 comments on commit 294c849

Please sign in to comment.