Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.appbasics.security.audit;
 
 import java.util.List;
 
 
Manages a list of IAuditItem objects.

Author(s):
Philip Helger
 
 final class AuditItemList
 {
   private final List <IAuditItemm_aItems = new ArrayList <IAuditItem> ();
 
   public AuditItemList ()
   {}
 
   void internalKeepOnlyLast ()
   {
     final IAuditItem aLastItem = ContainerHelper.getLastElement ();
     .clear ();
     .add (aLastItem);
   }
 
   void internalAddItem (@Nonnull final IAuditItem aItem)
   {
     ValueEnforcer.notNull (aItem"Item");
 
     .add (aItem);
   }
 
   public int getItemCount ()
   {
     return .size ();
   }
 
   @Nonnull
   public List <IAuditItemgetAllItems ()
   {
     return ContainerHelper.newList ();
   }
 
   @Nonnull
   public List <IAuditItemgetLastItems (@Nonnegative final int nMaxItems)
   {
     final int nEndIndex = Math.min (nMaxItems.size ());
     return ContainerHelper.getSorted (new ComparatorAuditItemDateTime (.))
                           .subList (0, nEndIndex);
   }
 
   @Override
   public boolean equals (final Object o)
   {
     if (o == this)
       return true;
     if (!(o instanceof AuditItemList))
       return false;
     final AuditItemList rhs = (AuditItemListo;
     return .equals (rhs.m_aItems);
   }
 
   @Override
   public int hashCode ()
   {
     return new HashCodeGenerator (this).append ().getHashCode ();
   }
 
  public String toString ()
  {
    return new ToStringGenerator (this).append ("items").toString ();
  }
New to GrepCode? Check out our FAQ X