public boolean matchesWithMask ( IPAddressSection other , IPAddressSection mask ) { checkMaskSectionCount ( mask ) ; checkSectionCount ( other ) ; int divCount = getSegmentCount ( ) ; for ( int i = 0 ; i < divCount ; i ++ ) { IPAddressSegment div = getSegment ( i ) ; IPAddressSegment maskSegment = mask . getSegment ( i ) ; IPAddressSegment otherSegment = other . getSegment ( i ) ; if ( ! div . matchesWithMask ( otherSegment . getSegmentValue ( ) , otherSegment . getUpperSegmentValue ( ) , maskSegment . getSegmentValue ( ) ) ) { return false ; } } return true ; }
Applies the mask to this address section and then compares values with the given address section