1

以下は私のクラスの構造です:

public class Address {
                private String street;
        private int phone;
        public void setStreet(String s){street = s;}
        public void setPhone(int p){phone = p;}
        public String getStreet(String s){return street;}
        public int getPhone(){  return phone;   }
}
public class Borrower {
    Address adr = new Address();
    public void setAddress(String s, int p) {
        adr.setStreet(s);
        adr.setPhone(p);
    }   
    public Address getAddress() {   return adr; }   
}

私が使用しているDrools式:-

rule "Nested Address"
    salience -10    
    when
        $bo : Borrower(Address.street.equals("USA") && Address.phone != 717)
        $loanApp : LoanApplication()        
    then 
        $loanApp.addFeedbackMessage(FeedbackMessages.LOCATION_NOT_US);  
        System.out.println("Nested Address  " + $bo.adr.street + ", Nested Phone " + $bo.adr.phone);
end

上記は私にエラーを与えます:

Unable to Analyse Expression Address.street.equals("USA"):

誰かが私が間違っていることを教えてもらえますか?

4

2 に答える 2

4

クラス Address ではなく、プロパティ名 "address" (小文字の a に注意してください) を使用する必要があります。それで:

rule "Nested Address"
    salience -10    
    when
        $bo : Borrower(address.street.equals("USA") && address.phone != 717)
        $loanApp : LoanApplication()        
    then 
        $loanApp.addFeedbackMessage(FeedbackMessages.LOCATION_NOT_US);  
        System.out.println("Nested Address  " + $bo.adr.street + ", Nested Phone " + $bo.adr.phone);
end
于 2013-10-13T17:07:57.873 に答える