src/main/java/org/jboss/util/LRUCachePolicy.java
/**
       * Promotes the cache entry <code>entry</code> to the last used position
       * of the list. <br>
       * If the object is already there, does nothing.
       * @param entry the object to be promoted, cannot be null
       * @see #demote
       * @throws IllegalStateException if this method is called with a full cache
       */
Promotes the cache entry entry to the last used position
of the list. 
If the object is already there, does nothing.
@param entry the object to be promoted, cannot be null
@see #demote
@throws IllegalStateException if this method is called with a full cache
Promotes the cache entry entry to the last used position of the list . If the object is already there does nothing . @param entry the object to be promoted cannot be null @see #demote @throws IllegalStateException if this method is called with a full cache
protected void promote(LRUCacheEntry entry)
      {
         if (entry == null) {throw new IllegalArgumentException("Trying to promote a null object");}
         if (m_capacity < 1) {throw new IllegalStateException("Can't work with capacity < 1");}
         entryPromotion(entry);
         entry.m_time = System.currentTimeMillis();
         if (entry.m_prev == null)
         {
            if (entry.m_next == null)
            {
               if (m_count == 0) 
               {
                  m_head = entry;
                  m_tail = entry;
                  ++m_count;
                  entryAdded(entry);
               }
               else if (m_count == 1 && m_head == entry) {} 
               else if (m_count < m_capacity)
               {
                  entry.m_prev = null;
                  entry.m_next = m_head;
                  m_head.m_prev = entry;
                  m_head = entry;
                  ++m_count;
                  entryAdded(entry);
               }
               else if (m_count < m_maxCapacity)
               {
                  entry.m_prev = null;
                  entry.m_next = m_head;
                  m_head.m_prev = entry;
                  m_head = entry;
                  ++m_count;
                  int oldCapacity = m_capacity;
                  ++m_capacity;
                  entryAdded(entry);
                  capacityChanged(oldCapacity);
               }
               else {throw new IllegalStateException("Attempt to put a new cache entry on a full cache");}
            }
            else {} 
         }
         else
         {
            if (entry.m_next == null) 
            {
               LRUCacheEntry beforeLast = entry.m_prev;
               beforeLast.m_next = null;
               entry.m_prev = null;
               entry.m_next = m_head;
               m_head.m_prev = entry;
               m_head = entry;
               m_tail = beforeLast;
            }
            else 
            {
               LRUCacheEntry previous = entry.m_prev;
               previous.m_next = entry.m_next;
               entry.m_next.m_prev = previous;
               entry.m_prev = null;
               entry.m_next = m_head;
               m_head.m_prev = entry;
               m_head = entry;
            }
         }
      }
protected void promote ( LRUCacheEntry entry ) { if ( entry == null ) { throw new IllegalArgumentException ( "Trying to promote a null object" ) ; } if ( m_capacity < 1 ) { throw new IllegalStateException ( "Can't work with capacity < 1" ) ; } entryPromotion ( entry ) ; entry . m_time = System . currentTimeMillis ( ) ; if ( entry . m_prev == null ) { if ( entry . m_next == null ) { if ( m_count == 0 ) { m_head = entry ; m_tail = entry ; ++ m_count ; entryAdded ( entry ) ; } else if ( m_count == 1 && m_head == entry ) { } else if ( m_count < m_capacity ) { entry . m_prev = null ; entry . m_next = m_head ; m_head . m_prev = entry ; m_head = entry ; ++ m_count ; entryAdded ( entry ) ; } else if ( m_count < m_maxCapacity ) { entry . m_prev = null ; entry . m_next = m_head ; m_head . m_prev = entry ; m_head = entry ; ++ m_count ; int oldCapacity = m_capacity ; ++ m_capacity ; entryAdded ( entry ) ; capacityChanged ( oldCapacity ) ; } else { throw new IllegalStateException ( "Attempt to put a new cache entry on a full cache" ) ; } } else { } } else { if ( entry . m_next == null ) { LRUCacheEntry beforeLast = entry . m_prev ; beforeLast . m_next = null ; entry . m_prev = null ; entry . m_next = m_head ; m_head . m_prev = entry ; m_head = entry ; m_tail = beforeLast ; } else { LRUCacheEntry previous = entry . m_prev ; previous . m_next = entry . m_next ; entry . m_next . m_prev = previous ; entry . m_prev = null ; entry . m_next = m_head ; m_head . m_prev = entry ; m_head = entry ; } } }
Promotes the cache entry <code>entry</code> to the last used position
 of the list.
Promotes the cache entry <code > entry< / code > to the last used position of the list .
// entry is new or there is only the head // cache is empty // there is only the head and I want to promote it, do nothing // entry is the head, do nothing // entry is the tail // entry is in the middle of the list