[jboss-svn-commits] JBL Code SVN: r31231 - labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 26 13:02:00 EST 2010


Author: baunax
Date: 2010-01-26 13:02:00 -0500 (Tue, 26 Jan 2010)
New Revision: 31231

Modified:
   labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java
Log:
added generics


Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java	2010-01-26 17:25:58 UTC (rev 31230)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/server/util/SuggestionCompletionEngineBuilder.java	2010-01-26 18:02:00 UTC (rev 31231)
@@ -15,12 +15,15 @@
  */
 package org.drools.guvnor.server.util;
 
-import java.util.*;
 import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.lang.reflect.ParameterizedType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.drools.guvnor.client.modeldriven.ModelField;
-
 import org.drools.guvnor.client.modeldriven.SuggestionCompletionEngine;
 import org.drools.guvnor.client.modeldriven.brl.DSLSentence;
 import org.drools.lang.dsl.DSLMappingEntry;
@@ -33,18 +36,18 @@
 public class SuggestionCompletionEngineBuilder {
 
     private SuggestionCompletionEngine instance = new SuggestionCompletionEngine();
-    private List factTypes = new ArrayList();
+    private List<String> factTypes = new ArrayList<String>();
     private Map<String, String[]> fieldsForType = new HashMap<String, String[]>();
-    private Map modifiersForType = new HashMap();
+    private Map<String, String[]> modifiersForType = new HashMap<String, String[]>();
     private Map<String, String> fieldTypes = new HashMap<String, String>();
-    private Map<String, Class> fieldClasses = new HashMap<String, Class>();
+    private Map<String, Class<?>> fieldClasses = new HashMap<String, Class<?>>();
     private Map<String, Field> fieldTypesField = new HashMap<String, Field>();
-    private Map globalTypes = new HashMap();
-    private List actionDSLSentences = new ArrayList();
-    private List conditionDSLSentences = new ArrayList();
-    private List keywordDSLItems = new ArrayList();
-    private List anyScopeDSLItems = new ArrayList();
-    private List<String> globalCollections = new ArrayList();
+    private Map<String, String> globalTypes = new HashMap<String, String>();
+    private List<DSLSentence> actionDSLSentences = new ArrayList<DSLSentence>();
+    private List<DSLSentence> conditionDSLSentences = new ArrayList<DSLSentence>();
+    private List<DSLSentence> keywordDSLItems = new ArrayList<DSLSentence>();
+    private List<DSLSentence> anyScopeDSLItems = new ArrayList<DSLSentence>();
+    private List<String> globalCollections = new ArrayList<String>();
 
     public SuggestionCompletionEngineBuilder() {
     }
@@ -54,16 +57,16 @@
      */
     public void newCompletionEngine() {
         this.instance = new SuggestionCompletionEngine();
-        this.factTypes = new ArrayList();
+        this.factTypes = new ArrayList<String>();
         this.fieldsForType = new HashMap<String, String[]>();
-        this.modifiersForType = new HashMap();
+        this.modifiersForType = new HashMap<String, String[]>();
         this.fieldTypes = new HashMap<String, String>();
         this.fieldTypesField = new HashMap<String, Field>();
-        this.globalTypes = new HashMap();
-        this.actionDSLSentences = new ArrayList();
-        this.conditionDSLSentences = new ArrayList();
-        this.keywordDSLItems = new ArrayList();
-        this.anyScopeDSLItems = new ArrayList();
+        this.globalTypes = new HashMap<String, String>();
+        this.actionDSLSentences = new ArrayList<DSLSentence>();
+        this.conditionDSLSentences = new ArrayList<DSLSentence>();
+        this.keywordDSLItems = new ArrayList<DSLSentence>();
+        this.anyScopeDSLItems = new ArrayList<DSLSentence>();
         this.globalCollections = new ArrayList<String>();
     }
 
@@ -116,7 +119,7 @@
      */
     public void addFieldType(final String field,
             final String type,
-            final Class clazz) {
+            final Class<?> clazz) {
         this.fieldTypes.put(field,
                 type);
         this.fieldClasses.put(field, clazz);
@@ -175,7 +178,7 @@
      * @return
      */
     public SuggestionCompletionEngine getInstance() {
-        this.instance.setFactTypes((String[]) this.factTypes.toArray(new String[this.factTypes.size()]));
+        this.instance.setFactTypes(this.factTypes.toArray(new String[this.factTypes.size()]));
         this.instance.setModifiers(this.modifiersForType);
 
 
@@ -187,7 +190,7 @@
             for (String field : typeEntry.getValue()) {
                 String fieldName = field;
                 String fieldType = this.fieldTypes.get(typeEntry.getKey() + "." + field);
-                Class fieldClazz = this.fieldClasses.get(typeEntry.getKey() + "." + field);
+                Class<?> fieldClazz = this.fieldClasses.get(typeEntry.getKey() + "." + field);
 
                 fields.add(new ModelField(
                         fieldName, fieldClazz, fieldType));
@@ -199,7 +202,7 @@
         this.instance.setFieldsForTypes(modelMap);
 
         for (String fieldName : this.fieldTypesField.keySet()) {
-            Field field = (Field) this.fieldTypesField.get(fieldName);
+            Field field = this.fieldTypesField.get(fieldName);
             if (field != null) {
                 Type type = field.getGenericType();
                 if (type instanceof ParameterizedType) {
@@ -245,8 +248,8 @@
         return this.instance;
     }
 
-    private DSLSentence[] makeArray(List ls) {
-        return (DSLSentence[]) ls.toArray(new DSLSentence[ls.size()]);
+    private DSLSentence[] makeArray(List<DSLSentence> ls) {
+        return ls.toArray(new DSLSentence[ls.size()]);
     }
 
     public void addDSLMapping(DSLMappingEntry entry) {



More information about the jboss-svn-commits mailing list