chaitu chaitu
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,"v endorIdLab el", ValidationConstants.MULTI_ VENDOR_VAL IDATION_NA ME,4);//ch anged validation code from 3 to 4
validationModel.addUserInp ut("Vendor (s)",userI nputModel) ;
}
any problem my bean class
public class HouseDocumentCharges implements Serializable,Cloneable
{
public String costIncurredAt;
public String chargeId;
public String chargeDescription;
public HouseDocumentCharges(Strin g chargeId) {
this.chargeId = chargeId;
}
public boolean equals(Object obj) {
return chargeId.equals( ((HouseDocumentCharges)obj ).chargeId );
}
public int hashCode() {
return chargeId.hashCode();
}
}
}
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,"v
validationModel.addUserInp
}
any problem my bean class
public class HouseDocumentCharges implements Serializable,Cloneable
{
public String costIncurredAt;
public String chargeId;
public String chargeDescription;
public HouseDocumentCharges(Strin
this.chargeId = chargeId;
}
public boolean equals(Object obj) {
return chargeId.equals( ((HouseDocumentCharges)obj
}
public int hashCode() {
return chargeId.hashCode();
}
}
}
because it contains an element with chargeid=620
ASKER
but chargeList also contains 162 chargeid naa...
ASKER
then what is the solution.................. .....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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" )) )
if (chargesList.contains( new HouseDocumentCharges("620"
chargesList.contains( new HouseDocumentCharges("621"