@Override
    public synchronized List<EntityAuditEvent> listEvents(String entityId, String startKey, short maxResults)
            throws AtlasException {
        List<EntityAuditEvent> events = new ArrayList<>();
        String myStartKey = startKey;
        if (myStartKey == null) {
            myStartKey = entityId;
        }
        SortedMap<String, EntityAuditEvent> subMap = auditEvents.tailMap(myStartKey);
        for (EntityAuditEvent event : subMap.values()) {
            if (events.size() < maxResults && event.getEntityId().equals(entityId)) {
                events.add(event);
            }
        }
        return events;
    }
@ Override public synchronized List < EntityAuditEvent > listEvents ( String entityId , String startKey , short maxResults ) throws AtlasException { List < EntityAuditEvent > events = new ArrayList < > ( ) ; String myStartKey = startKey ; if ( myStartKey == null ) { myStartKey = entityId ; } SortedMap < String , EntityAuditEvent > subMap = auditEvents . tailMap ( myStartKey ) ; for ( EntityAuditEvent event : subMap . values ( ) ) { if ( events . size ( ) < maxResults && event . getEntityId ( ) . equals ( entityId ) ) { events . add ( event ) ; } } return events ; }
while we are iterating through the map