public boolean equals()

in modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java [931:1003]


    public boolean equals( JMSBinding binding ) {
        // If the target namespace is set, this binding came from a definitions document.
        // The target namespace and name are used as keys for doing model resolver hashmap lookups.
        // Only the target namespace and name can be compared.
        if (this.targetNamespace != null) {
            if ( !optStringEquals( this.targetNamespace, binding.getTargetNamespace() )) return false;
            if ( !optStringEquals( this.name, binding.getName() )) return false;
            return true;
        }

        // Test all fields for equality.
        // First test simple fields to quickly weed out mismatches.
        if ( !optStringEquals( this.uri, binding.getURI() )) return false;
        if ( !optStringEquals( this.name, binding.getName() )) return false;
        if ( !optStringEquals( this.targetNamespace, binding.getTargetNamespace() )) return false;
        if ( !optStringEquals( this.destinationName, binding.getDestinationName() )) return false;
        if ( !optStringEquals( this.correlationScheme, binding.getCorrelationScheme() )) return false;
        if ( !optStringEquals( this.initialContextFactoryName, binding.getInitialContextFactoryName() )) return false;
        if ( !optStringEquals( this.jndiURL, binding.getJndiURL() )) return false;
        if ( !optStringEquals( this.requestConnectionName, binding.getRequestConnectionName() )) return false;
        if ( !optStringEquals( this.responseConnectionName, binding.getResponseConnectionName() )) return false;
        if ( !optStringEquals( this.jmsSelector, binding.getJMSSelector() )) return false;
        if ( !equals( properties, binding.getProperties()) )
            return false;

        // Test operation properties
        Set<String> operationNamesA = this.getOperationNames();
        Set<String> operationNamesB = binding.getOperationNames();
        if ( operationNamesA != null && operationNamesB != null ) {
            if ( operationNamesA == null && operationNamesB != null ) return false;     
            if ( operationNamesA != null && operationNamesB == null ) return false;     
            if ( operationNamesA.size() != operationNamesB.size() ) return false;     
            for(Iterator<String> it=operationNamesA.iterator(); it.hasNext(); ) {
                String opName = it.next();
                if ( !operationNamesB.contains( opName )) {
                    return false;
                }
            }        
        }

        // Destination properties
        if ( !optStringEquals( this.getDestinationName(), binding.getDestinationName() )) return false;
        if ( !optStringEquals( this.getDestinationType(), binding.getDestinationType() )) return false;

        // Connection factory properties
        if ( !optStringEquals( this.getConnectionFactoryName(), binding.getConnectionFactoryName() )) return false;

        // Activation spec properties
        if ( !optStringEquals( this.getActivationSpecName(), binding.getActivationSpecName() )) return false;

        // Response properties
        if ( !optStringEquals( this.getResponseDestinationName(), binding.getResponseDestinationName() )) return false;
        if ( !optStringEquals( this.getResponseActivationSpecName(), binding.getResponseActivationSpecName() )) return false;
        if ( !optStringEquals( this.getResponseConnectionFactoryName(), binding.getResponseConnectionFactoryName() )) return false;

        // Resource adapter
        if ( !optStringEquals( this.getResourceAdapterName(), binding.getResourceAdapterName() )) return false;

        // Configured operations
        if ( this.configuredOperations.size() != binding.getConfiguredOperations().size() ) return false;
        
        // wire format
        if ( this.getRequestWireFormat().getClass() != binding.getRequestWireFormat().getClass()) return false;
        if ( this.getResponseWireFormat().getClass() != binding.getResponseWireFormat().getClass()) return false;
        if ( this.isResponseWireFormatDefault() != binding.isResponseWireFormatDefault()) return false;
        
        // operation selector
        if ( this.getOperationSelector().getClass() != binding.getOperationSelector().getClass()) return false;
        
        
        // Other fields could also be checked for equality. See class fields for details.
        return true;
    }