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.password.constraint;
 
 import java.util.List;
 
 
The default implementation of IPasswordConstraintList.

Author(s):
Philip Helger
 
 {
   private final List <IPasswordConstraintm_aConstraints = new ArrayList <IPasswordConstraint> ();
 
   public PasswordConstraintList ()
   {}
 
   public PasswordConstraintList (@Nonnull final IPasswordConstraintList aOther)
   {
     ValueEnforcer.notNull (aOther"Other");
   }
 
   public PasswordConstraintList (@Nullable final IPasswordConstraint... aPasswordConstraints)
   {
     if (aPasswordConstraints != null)
       for (final IPasswordConstraint aPasswordConstraint : aPasswordConstraints)
         addConstraint (aPasswordConstraint);
   }
 
   public PasswordConstraintList (@Nullable final Iterable <? extends IPasswordConstraintaPasswordConstraints)
   {
     if (aPasswordConstraints != null)
       for (final IPasswordConstraint aPasswordConstraint : aPasswordConstraints)
         addConstraint (aPasswordConstraint);
   }
 
   public boolean hasConstraints ()
   {
     return !.isEmpty ();
   }
 
   public int getConstraintCount ()
   {
     return .size ();
   }
 
   @Nonnull
   {
     return ContainerHelper.newList ();
   }

  
Added a password constraint.

Parameters:
aPasswordConstraint The constraint to be added. May not be null.
Returns:
this
 
   @Nonnull
   public PasswordConstraintList addConstraint (@Nonnull final IPasswordConstraint aPasswordConstraint)
   {
     ValueEnforcer.notNull (aPasswordConstraint"PasswordConstraint");
     .add (aPasswordConstraint);
     return this;
   }

  
Remove the passed constraint.

Parameters:
aPasswordConstraint The constraint to be removed. May be null.
Returns:
com.helger.commons.state.EChange.
  public EChange removeConstraint (@Nullable final IPasswordConstraint aPasswordConstraint)
  {
    if (aPasswordConstraint == null)
      return .;
    return EChange.valueOf (.remove (aPasswordConstraint));
  }
  public boolean isPasswordValid (@Nullable final String sPlainTextPassword)
  {
    for (final IPasswordConstraint aPasswordConstraint : )
      if (!aPasswordConstraint.isPasswordValid (sPlainTextPassword))
        return false;
    return true;
  }
  public List <StringgetInvalidPasswordDescriptions (@Nullable final String sPlainTextPassword,
                                                       @Nonnull final Locale aContentLocale)
  {
    final List <Stringret = new ArrayList <String> ();
    for (final IPasswordConstraint aPasswordConstraint : )
      if (!aPasswordConstraint.isPasswordValid (sPlainTextPassword))
        ret.add (aPasswordConstraint.getDescription (aContentLocale));
    return ret;
  }
  public List <StringgetAllPasswordConstraintDescriptions (@Nonnull final Locale aContentLocale)
  {
    final List <Stringret = new ArrayList <String> ();
    for (final IPasswordConstraint aPasswordConstraint : )
      ret.add (aPasswordConstraint.getDescription (aContentLocale));
    return ret;
  }
  {
    return new PasswordConstraintList (this);
  }
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (o == null || !getClass ().equals (o.getClass ()))
      return false;
    return .equals (rhs.m_aConstraints);
  }
  public int hashCode ()
  {
    return new HashCodeGenerator (this).append ().getHashCode ();
  }
  public String toString ()
  {
    return new ToStringGenerator (this).append ("constraints").toString ();
  }
New to GrepCode? Check out our FAQ X