Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove spurious Sys.outs, unnecessary dependencies

  • Loading branch information...
commit 8274333ff4dfaa7518bd1a6f7c11f3c6e90ef02e 1 parent 99e2513
@sotty sotty authored
View
85 drools-chance-core/src/main/java/org/drools/chance/common/ChanceStrategyFactory.java
@@ -16,7 +16,6 @@
package org.drools.chance.common;
-import com.google.common.collect.HashBasedTable;
import org.drools.chance.rule.constraint.core.connectives.ConnectiveFactory;
import org.drools.chance.rule.constraint.core.connectives.factories.fuzzy.linguistic.FuzzyConnectiveFactory;
import org.drools.chance.rule.constraint.core.connectives.factories.fuzzy.mvl.ManyValuedConnectiveFactory;
@@ -30,6 +29,8 @@
import org.drools.chance.distribution.ImpKind;
import org.drools.chance.distribution.ImpType;
+import java.util.HashMap;
+
/**
* Level I (master) factory.
@@ -55,20 +56,36 @@
public class ChanceStrategyFactory<T> {
- private static HashBasedTable<ImpKind,ImpType,ConnectiveFactory> cacheConnective = HashBasedTable.create();
+
+ private static HashMap<Pair<ImpKind,ImpType>,ConnectiveFactory> cacheConnective = new HashMap<Pair<ImpKind, ImpType>, ConnectiveFactory>();
private static ConnectiveFactory defaultFactory = new ManyValuedConnectiveFactory();
static {
- cacheConnective.put( ImpKind.PROBABILITY, ImpType.DISCRETE, new DiscreteProbabilityConnectiveFactory() );
- cacheConnective.put( ImpKind.PROBABILITY, ImpType.DIRICHLET, new DiscreteProbabilityConnectiveFactory() );
- cacheConnective.put( ImpKind.FUZZINESS, ImpType.LINGUISTIC, new FuzzyConnectiveFactory() );
- cacheConnective.put( ImpKind.FUZZINESS, ImpType.MVL, new ManyValuedConnectiveFactory() );
- cacheConnective.put( ImpKind.FUZZINESS, ImpType.BASIC, new ManyValuedConnectiveFactory() );
- cacheConnective.put( ImpKind.PROBABILITY, ImpType.BASIC, new ManyValuedConnectiveFactory() );
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.PROBABILITY, ImpType.DISCRETE ),
+ new DiscreteProbabilityConnectiveFactory() );
+
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.PROBABILITY, ImpType.DIRICHLET ),
+ new DiscreteProbabilityConnectiveFactory() );
+
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.FUZZINESS, ImpType.LINGUISTIC ),
+ new FuzzyConnectiveFactory() );
+
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.FUZZINESS, ImpType.MVL ),
+ new ManyValuedConnectiveFactory() );
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.FUZZINESS, ImpType.BASIC ),
+ new ManyValuedConnectiveFactory() );
+ cacheConnective.put(
+ new Pair<ImpKind, ImpType>( ImpKind.PROBABILITY, ImpType.BASIC ),
+ new ManyValuedConnectiveFactory() );
}
public static void registerConnectiveFactory( ImpKind kind, ImpType model, ConnectiveFactory connFac ) {
- cacheConnective.put( kind, model, connFac );
+ cacheConnective.put( new Pair<ImpKind, ImpType>( kind, model ), connFac );
}
@@ -76,7 +93,7 @@ public static ConnectiveFactory getConnectiveFactory( ImpKind kind, ImpType mode
if ( kind == null || model == null ) {
return defaultFactory;
}
- return cacheConnective.get( kind, model );
+ return cacheConnective.get( new Pair<ImpKind, ImpType>( kind, model ) );
}
public static void setDefaultFactory(ConnectiveFactory defaultFactory) {
@@ -89,19 +106,19 @@ public static void setDefaultFactory(ConnectiveFactory defaultFactory) {
- private static HashBasedTable<ImpKind,ImpType,DistributionStrategyFactory> cache
- = HashBasedTable.create();
+ private static HashMap<Pair<ImpKind,ImpType>,DistributionStrategyFactory> cache
+ = new HashMap<Pair<ImpKind, ImpType>, DistributionStrategyFactory>();
public static <T> DistributionStrategies buildStrategies(
ImpKind kind, ImpType model, DegreeType degreeType, Class<T> domainType) {
- DistributionStrategyFactory<T> factory = cache.get(kind,model);
+ DistributionStrategyFactory<T> factory = cache.get( new Pair( kind,model ) );
return factory.<T>buildStrategies( degreeType, domainType );
}
public static <T> void register( ImpKind kind, ImpType model, DistributionStrategyFactory<T> factory ) {
- cache.put( kind, model, factory );
+ cache.put( new Pair<ImpKind, ImpType>( kind, model ), factory );
}
@@ -179,6 +196,46 @@ public static void initDefaults() {
+ private static class Pair<X,Y> {
+
+ private X x;
+ private Y y;
+
+ Pair( X x, Y y ) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public X getX() {
+ return x;
+ }
+
+ public Y getY() {
+ return y;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Pair pair = (Pair) o;
+
+ if (!x.equals(pair.x)) return false;
+ if (!y.equals(pair.y)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = x.hashCode();
+ result = 31 * result + y.hashCode();
+ return result;
+ }
+ }
+
+
View
2  drools-chance-core/src/main/java/org/drools/chance/rule/constraint/core/connectives/impl/godel/Not.java
@@ -1,7 +1,5 @@
package org.drools.chance.rule.constraint.core.connectives.impl.godel;
-
-import com.sun.org.apache.bcel.internal.generic.INSTANCEOF;
import org.drools.chance.rule.constraint.core.connectives.ConnectiveCore;
import org.drools.chance.rule.constraint.core.connectives.impl.LogicConnectives;
import org.drools.chance.degree.Degree;
View
4 drools-informer/drools-informer-core/src/main/resources/org/drools/informer/ReadOnly.drl
@@ -38,7 +38,6 @@ when
presentationStyles contains "readonly" || presentationStyles contains "readonly-inherited" )
)
then
- System.out.println( "Rule A " + $item.getType() );
modify ( $item ) {
addPresentationStyle( "readonly-inherited" );
}
@@ -55,7 +54,6 @@ when
presentationStyles contains "readonly" || presentationStyles contains "readonly-inherited" )
)
then
- System.out.println("Rule B " + $item.getType());
modify ( $item ) {
addPresentationStyle( "readonly-inherited" );
}
@@ -75,7 +73,6 @@ when
presentationStyles contains "readonly" || presentationStyles contains "readonly-inherited" )
)
then
- System.out.println("Rule C" + $item.getType());
modify ( $item ) {
removePresentationStyle( "readonly-inherited" );
}
@@ -93,7 +90,6 @@ when
presentationStyles contains "readonly" || presentationStyles contains "readonly-inherited" )
)
then
- System.out.println("Rule D" + $item.getType());
modify ( $item ) {
removePresentationStyle( "readonly-inherited" );
}
View
2  drools-informer/drools-informer-core/src/main/resources/org/drools/informer/Status.drl
@@ -124,7 +124,7 @@ when
Size( formId == $formId, $max : num > 0 )
then
Progress p = new Progress( $formId, (int) Math.round( 100.0 * $num.doubleValue() / $max ) );
- System.out.println( "Making progress.... " + p );
+// System.out.println( "Making progress.... " + p );
insertLogical( p );
end
View
6 ...former/drools-informer-core/src/main/resources/org/drools/informer/presentation/presentation_adapter.drl
@@ -324,7 +324,7 @@ when
$p : ProgressStatus( $formId, $percentage ; )
$s : SurveyGUIAdapter( itemId == $formId, progress != $percentage )
then
- System.out.println("SETTING GUI PROGRESS TO " + $percentage );
+// System.out.println("SETTING GUI PROGRESS TO " + $percentage );
modify ( $s ) {
setProgress( $percentage );
}
@@ -336,7 +336,7 @@ rule "Invalidations"
when
InvalidAnswer( $qid : questionId, $msg : reason, $type : type != "missing" )
then
- System.out.println( "INVALIDATE ! " + $qid + " due to " + $type );
+// System.out.println( "INVALIDATE ! " + $qid + " due to " + $type );
insert( new QuestionInvalidate( $qid ) );
end
@@ -344,7 +344,7 @@ rule "Finalizations"
when
Question( $qid : id, finalAnswer == true, answered == true )
then
- System.out.println( "FINALIZE ! " + $qid );
+// System.out.println( "FINALIZE ! " + $qid );
insert( new QuestionFinalize( $qid ) );
end
Please sign in to comment.
Something went wrong with that request. Please try again.