/** * returns the type of parametric class List<String> a in a class called * Toto key = "Toto.a" value = "String" */ public String getParametricFieldType(final String factType, final String fieldName) { return this.getParametricFieldType( factType + "." + fieldName ); }
/** * returns the type of parametric class List<String> a in a class called * Toto key = "Toto.a" value = "String" */ public String getParametricFieldType(final String factType, final String fieldName) { return this.getParametricFieldType( factType + "." + fieldName ); }
public static ExpressionPart getExpressionPartForField(SuggestionCompletionEngine sce, String factName, String fieldName) { String fieldClassName = sce.getFieldClassName(factName, fieldName); String fieldGenericType = sce.getFieldType(factName, fieldName); if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(fieldGenericType)) { String fieldParametricType = sce.getParametricFieldType(factName, fieldName); return new ExpressionCollection(fieldName, fieldClassName, fieldGenericType, fieldParametricType); } return new ExpressionField(fieldName, fieldClassName, fieldGenericType); }
public static ExpressionPart getExpressionPartForField(SuggestionCompletionEngine sce, String factName, String fieldName) { String fieldClassName = sce.getFieldClassName(factName, fieldName); String fieldGenericType = sce.getFieldType(factName, fieldName); if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(fieldGenericType)) { String fieldParametricType = sce.getParametricFieldType(factName, fieldName); return new ExpressionCollection(fieldName, fieldClassName, fieldGenericType, fieldParametricType); } return new ExpressionField(fieldName, fieldClassName, fieldGenericType); }
@Test public void testLoadDifferentMethodTypes() throws Exception { SuggestionCompletionLoader loader = new SuggestionCompletionLoader(); SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.ide.common.server.rules.SomeFact", new ArrayList(), new ArrayList() ); assertNotNull( eng ); assertEquals( List.class.getName(), eng.getMethodClassType( "SomeFact", "aMethod(int)" ) ); assertEquals( "SomeFact", eng.getParametricFieldType( "SomeFact", "aMethod(int)" ) ); }
"bananas" ) ); assertEquals( "Banana", suggestionCompletionEngine.getParametricFieldType( "Person", "bananas" ) );
eng.getParametricFieldType( "SomeFact", "factList" ) ); assertEquals( SuggestionCompletionEngine.TYPE_COLLECTION, "factListString" ) ); assertEquals( "String", eng.getParametricFieldType( "SomeFact", "factListString" ) );