/** * Returns fact's name from class type * * @param type * @return */ public String getFactNameFromType(String type) { if ( type == null ) { return null; } if ( getModelFields().containsKey( type ) ) { return type; } for ( Map.Entry<String, ModelField[]> entry : getModelFields().entrySet() ) { for ( ModelField mf : entry.getValue() ) { if ( TYPE_THIS.equals( mf.getName() ) && type.equals( mf.getClassName() ) ) { return entry.getKey(); } } } return null; }
public ModelField.FIELD_CLASS_TYPE getFieldClassType(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getClassType(); }
public String getFieldType(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getType(); }
+ "." + field); fields.add(new ModelField(fieldName, fieldClazz == null ? fieldType : fieldClazz.getName(), this.factTypes.get(typeEntry.getKey()), fieldType));
public ModelField getField(String modelClassName, String fieldName) { String shortName = this.getFactNameFromType( modelClassName ); ModelField[] fields = this.getModelFields().get( shortName ); if ( fields == null ) { return null; } for ( ModelField modelField : fields ) { if ( modelField.getName().equals( fieldName ) ) { return modelField; } } return null; }
public String getFieldClassName(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getClassName(); }
+ "." + field); fields.add(new ModelField(fieldName, fieldClazz == null ? fieldType : fieldClazz.getName(), this.factTypes.get(typeEntry.getKey()), fieldType));
public ModelField getField(String modelClassName, String fieldName) { String shortName = this.getFactNameFromType( modelClassName ); ModelField[] fields = this.getModelFields().get( shortName ); if ( fields == null ) { return null; } for ( ModelField modelField : fields ) { if ( modelField.getName().equals( fieldName ) ) { return modelField; } } return null; }
public String getFieldClassName(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getClassName(); }
new ModelField( "this", Object.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS,
/** * Returns fact's name from class type * * @param type * @return */ public String getFactNameFromType(String type) { if ( type == null ) { return null; } if ( getModelFields().containsKey( type ) ) { return type; } for ( Map.Entry<String, ModelField[]> entry : getModelFields().entrySet() ) { for ( ModelField mf : entry.getValue() ) { if ( TYPE_THIS.equals( mf.getName() ) && type.equals( mf.getClassName() ) ) { return entry.getKey(); } } } return null; }
public String[] getModelFields(String modelClassName) { String shortName = this.getFactNameFromType( modelClassName ); if ( !this.getModelFields().containsKey( shortName ) ) { return new String[0]; } ModelField[] fields = this.getModelFields().get( shortName ); String[] fieldNames = new String[fields.length]; for ( int i = 0; i < fields.length; i++ ) { fieldNames[i] = fields[i].getName(); } return fieldNames; }
public String getFieldType(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getType(); }
public ModelField.FIELD_CLASS_TYPE getFieldClassType(String modelClassName, String fieldName) { ModelField field = this.getField( modelClassName, fieldName ); return field == null ? null : field.getClassType(); }
@Test public void testGlobalAndFacts() { final SuggestionCompletionEngine com = new SuggestionCompletionEngine(); com.setGlobalVariables( new HashMap<String, String>() { { put( "y", "Foo" ); } } ); com.setFieldsForTypes( new HashMap<String, ModelField[]>() { { put( "Foo", new ModelField[]{ new ModelField( "a", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, "String" ) } ); } } ); assertFalse( com.isGlobalVariable( "x" ) ); assertTrue( com.isGlobalVariable( "y" ) ); }
public String[] getModelFields(String modelClassName) { String shortName = this.getFactNameFromType( modelClassName ); if ( !this.getModelFields().containsKey( shortName ) ) { return new String[0]; } ModelField[] fields = this.getModelFields().get( shortName ); String[] fieldNames = new String[fields.length]; for ( int i = 0; i < fields.length; i++ ) { fieldNames[i] = fields[i].getName(); } return fieldNames; }
new ModelField( "age", Integer.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ), new ModelField( "name", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS,
public String[] getModelFields(FieldAccessorsAndMutators accessorOrMutator, String modelClassName) { String shortName = this.getFactNameFromType( modelClassName ); if ( !this.getModelFields().containsKey( shortName ) ) { return new String[0]; } ModelField[] fields = this.getModelFields().get( shortName ); List<String> fieldNames = new ArrayList<String>(); for ( int i = 0; i < fields.length; i++ ) { String fieldName = fields[i].getName(); if ( FieldAccessorsAndMutators.compare( accessorOrMutator, this.accessorsAndMutators.get( shortName + "." + fieldName ) ) ) { fieldNames.add( fieldName ); } } return fieldNames.toArray( new String[fieldNames.size()] ); }
new ModelField( "age", Integer.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ), new ModelField( "name", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS,
public String[] getModelFields(FieldAccessorsAndMutators accessorOrMutator, String modelClassName) { String shortName = this.getFactNameFromType( modelClassName ); if ( !this.getModelFields().containsKey( shortName ) ) { return new String[0]; } ModelField[] fields = this.getModelFields().get( shortName ); List<String> fieldNames = new ArrayList<String>(); for ( int i = 0; i < fields.length; i++ ) { String fieldName = fields[i].getName(); if ( FieldAccessorsAndMutators.compare( accessorOrMutator, this.accessorsAndMutators.get( shortName + "." + fieldName ) ) ) { fieldNames.add( fieldName ); } } return fieldNames.toArray( new String[fieldNames.size()] ); }