Link to home
Start Free TrialLog in
Avatar of chaitu chaitu
chaitu chaituFlag for India

asked on

contains method still not validating properly? any problem my bean class

contains method still not validating properly

in the chargelist i have charges 162,620;

chargelist contains other than 620 i.e 162 chargeid exists in the list why it is not entering into if loop;


   if(chargesList!=null && chargesList.size()>0)
            {
    if (!chargesList.contains( new HouseDocumentCharges("620")) )
    {
                        userInputModel = new UserInputModel(vndrList,"vendorIdLabel", ValidationConstants.MULTI_VENDOR_VALIDATION_NAME,4);//changed validation code from 3 to 4
                        validationModel.addUserInput("Vendor(s)",userInputModel);
    }


 any problem my bean class

public class HouseDocumentCharges implements Serializable,Cloneable
{

      public String            costIncurredAt;
      
      public String            chargeId;
      public String            chargeDescription;
      

       public HouseDocumentCharges(String chargeId) {
       this.chargeId = chargeId;
   }

  public boolean equals(Object obj) {
       return chargeId.equals( ((HouseDocumentCharges)obj).chargeId );
   }
   public int hashCode() {
       return chargeId.hashCode();
   }

}
    }
Avatar of Mick Barry
Mick Barry
Flag of Australia image

because it contains an element with chargeid=620
Avatar of chaitu chaitu

ASKER

but chargeList also contains 162 chargeid naa...
then what is the solution.......................
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
fpr example if you want it to return true if it contains 620 or 621 then use:

    if (chargesList.contains( new HouseDocumentCharges("620")) ||
        chargesList.contains( new HouseDocumentCharges("621"))  )