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.lock;
 
 import java.util.List;
 
 
This class contains the result of a locking operation.

Parameters:
<IDTYPE> The type of the ID of the locked object.
Author(s):
Philip Helger
 
 public final class LockResult <IDTYPE> implements ILockedIndicator
 {
   private final IDTYPE m_aObjID;
   private final ELocked m_eLocked;
   private final boolean m_bIsNewLock;
   private final List <IDTYPE> m_aUnlockedObjects;
 
   public LockResult (@Nonnull final IDTYPE aObjID,
                      @Nonnull final ELocked eLocked,
                      final boolean bIsNewLock,
                      @Nullable final List <IDTYPE> aUnlockedObjects)
   {
      = ValueEnforcer.notNull (aObjID"ObjectID");
      = ValueEnforcer.notNull (eLocked"Locked");
      = bIsNewLock;
      = ContainerHelper.newList (aUnlockedObjects);
   }

  

Returns:
The ID of the locked object. Never null.
 
   @Nonnull
   public IDTYPE getLockedObjectID ()
   {
     return ;
   }
 
   public boolean isLocked ()
   {
     return .isLocked ();
   }
 
   public boolean isNotLocked ()
   {
     return .isNotLocked ();
   }

  

Returns:
true if the lock was just created or false if the object was already locked.
 
   public boolean isNewLock ()
   {
     return ;
   }

  

Returns:
A list with all objects that were unlocked during the locking process. Never null but maybe empty.
 
   @Nonnull
   public List <IDTYPE> getUnlockedObjects ()
   {
     return ContainerHelper.newList ();
   }
 
   @Override
   public boolean equals (final Object o)
   {
     if (o == this)
      return true;
    if (!(o instanceof LockResult))
      return false;
    final LockResult <?> rhs = (LockResult <?>) o;
    return .equals (rhs.m_aObjID) &&
           .equals (rhs.m_eLocked) &&
            == rhs.m_bIsNewLock &&
           .equals (rhs.m_aUnlockedObjects);
  }
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append ()
                                       .append ()
                                       .append ()
                                       .append ()
                                       .getHashCode ();
  }
  public String toString ()
  {
    return new ToStringGenerator (this).append ("objID")
                                       .append ("locked")
                                       .append ("isNewLock")
                                       .appendIfNotEmpty ("unlockedObjects")
                                       .toString ();
  }
  public static <IDTYPE> LockResult <IDTYPE> createFailure (@Nonnull final IDTYPE aObjID)
  {
    return new LockResult <IDTYPE> (aObjID.falsenull);
  }
New to GrepCode? Check out our FAQ X