def merge_attributes(other, attributes=nil, matches=nil, &filter)
      return self if other.nil? or other.equal?(self)
      attributes = [attributes] if Symbol === attributes
      attributes ||= self.class.mergeable_attributes
      # If the source object is not a hash, then convert it to an attribute => value hash.
      vh = Hasher === other ? other : other.value_hash(attributes)
      # Merge the Java values hash.
      vh.each { |pa, value| merge_attribute(pa, value, matches, &filter) }
      self
    end
def merge_attributes(other, attributes=nil, matches=nil, &filter)
      return self if other.nil? or other.equal?(self)
      attributes = [attributes] if Symbol === attributes
      attributes ||= self.class.mergeable_attributes
      # If the source object is not a hash, then convert it to an attribute => value hash.
      vh = Hasher === other ? other : other.value_hash(attributes)
      # Merge the Java values hash.
      vh.each { |pa, value| merge_attribute(pa, value, matches, &filter) }
      self
    end
Merges the values of the other attributes into this object and returns self.
 The other argument can be either a Hash or an object whose class responds to the
 +mergeable_attributes+ method.
 The optional attributes argument can be either a single attribute symbol or a
 collection of attribute symbols.

 A hash argument consists of attribute name => value associations.
 For example, given a Mergeable +person+ object with attributes +ssn+ and +children+, the call:
   person.merge_attributes(:ssn => '555-55-5555', :children => children)
 is equivalent to:
   person.ssn ||= '555-55-5555'
   person.children ||= []
   person.children.merge(children, :deep)
 An unrecognized attribute is ignored.

 If other is not a Hash, then the other object's attributes values are merged into
 this object. The default attributes is this mergeable's class
 {Propertied#mergeable_attributes}.

 The merge is performed by calling {#merge_attribute} on each attribute with the matches
 and filter block given to this method.

 @param [Mergeable, {Symbol => Object}] other the source domain object or value hash to merge from
 @param [<Symbol>, nil] attributes the attributes to merge (default {Propertied#nondomain_attributes})
 @param [{Resource => Resource}, nil] the optional merge source => target reference matches
 @yield [value] the optional filter block
 @yieldparam value the source merge attribute value
 @return [Mergeable] self
 @raise [ArgumentError] if none of the following are true:
   * other is a Hash
   * attributes is non-nil
   * the other class responds to +mergeable_attributes+