/** * Check whether a given FactType has been annotated as an Event * * @param factType * @return */ public boolean isFactTypeAnEvent(String factType) { List<ModelAnnotation> annotations = this.annotationsForTypes.get( factType ); if ( annotations == null || annotations.size() == 0 ) { return false; } for ( ModelAnnotation ma : annotations ) { if ( ma.getAnnotationName().equals( ANNOTATION_ROLE ) ) { for ( String v : ma.getAnnotationValues().values() ) { if ( v.equals( ANNOTATION_ROLE_EVENT ) ) { return true; } } } } return false; }
for (Map.Entry<String, Map<String, String>> annotationEntry : factTypeEntry .getValue().entrySet()) { ModelAnnotation ma = new ModelAnnotation(); ma.setAnnotationName(annotationEntry.getKey()); ma.setAnnotationValues(annotationEntry.getValue()); annotations.add(ma);
private int getIndexOfAnnotation(List<ModelAnnotation> annotations, String annotationName) { for ( int i = 0; i < annotations.size(); i++ ) { ModelAnnotation annotation = annotations.get( i ); if ( annotationName.equals( annotation.getAnnotationName() ) ) { return i; } } return -1; }
for (Map.Entry<String, Map<String, String>> annotationEntry : factTypeEntry .getValue().entrySet()) { ModelAnnotation ma = new ModelAnnotation(); ma.setAnnotationName(annotationEntry.getKey()); ma.setAnnotationValues(annotationEntry.getValue()); annotations.add(ma);
ModelAnnotation ma = new ModelAnnotation(); ma.setAnnotationName( "role" ); Map<String, String> mav = new HashMap<String, String>(); mav.put( "value", "event" ); ma.setAnnotationValues( mav ); eventAnnotations.add( ma ); annotations.put( "AnEvent",
/** * Check whether a given FactType has been annotated as an Event * * @param factType * @return */ public boolean isFactTypeAnEvent(String factType) { List<ModelAnnotation> annotations = this.annotationsForTypes.get( factType ); if ( annotations == null || annotations.size() == 0 ) { return false; } for ( ModelAnnotation ma : annotations ) { if ( ma.getAnnotationName().equals( ANNOTATION_ROLE ) ) { for ( String v : ma.getAnnotationValues().values() ) { if ( v.equals( ANNOTATION_ROLE_EVENT ) ) { return true; } } } } return false; }
ModelAnnotation ma = new ModelAnnotation(); ma.setAnnotationName( "role" ); Map<String, String> mav = new HashMap<String, String>(); mav.put( "value", "event" ); ma.setAnnotationValues( mav ); eventAnnotations.add( ma ); annotations.put( "AnEvent",
@Test public void testTypeDeclarationsAnnotations() throws Exception { SuggestionCompletionLoader loader = new SuggestionCompletionLoader(); String header = ""; header += "package foo\n"; header += "declare Applicant\n"; header += "@role( event )\n"; header += "end\n"; SuggestionCompletionEngine eng = loader.getSuggestionEngine( header, new ArrayList(), new ArrayList() ); assertNotNull( eng ); assertNotNull( eng.getAnnotations() ); assertEquals( 1, eng.getAnnotations().size() ); assertNotNull( eng.getAnnotations().get( "Applicant" ) ); assertEquals( 1, eng.getAnnotations().get( "Applicant" ).size() ); assertNotNull( eng.getAnnotations().get( "Applicant" ).get( 0 ) ); assertEquals( "role", eng.getAnnotations().get( "Applicant" ).get( 0 ).getAnnotationName() ); assertEquals( "event", eng.getAnnotations().get( "Applicant" ).get( 0 ).getAnnotationValues().get( "value" ) ); assertNotNull( eng.getAnnotationsForFactType( "Applicant" ) ); assertNotNull( eng.getAnnotationsForFactType( "Applicant" ).get( 0 ) ); assertEquals( "role", eng.getAnnotationsForFactType( "Applicant" ).get( 0 ).getAnnotationName() ); assertEquals( "event", eng.getAnnotationsForFactType( "Applicant" ).get( 0 ).getAnnotationValues().get( "value" ) ); }
eng.getAnnotations().get( "Applicant" ).get( idx0 ).getAnnotationName() ); assertEquals( "event", eng.getAnnotations().get( "Applicant" ).get( idx0 ).getAnnotationValues().get( "value" ) ); eng.getAnnotations().get( "Applicant" ).get( idx1 ).getAnnotationName() ); assertEquals( "Pupa", eng.getAnnotations().get( "Applicant" ).get( idx1 ).getAnnotationValues().get( "name" ) );