Module: javajava::util::Collection
- Defined in:
- lib/logstash/java_integration.rb
Instance Method Summary collapse
-
#&(other) ⇒ Object
support the Ruby intersection method on Java Collection.
- #compact ⇒ Object
- #compact! ⇒ Object
-
#delete(o) ⇒ Object
support the Ruby Array delete method on a Java Collection.
- #inspect ⇒ Object
-
#is_a?(clazz) ⇒ Boolean
have Collections objects like ArrayList report is_a?(Array) == true.
-
#|(other) ⇒ Object
support the Ruby union method on Java Collection.
Instance Method Details
#&(other) ⇒ Object
support the Ruby intersection method on Java Collection
98 99 100 101 102 103 |
# File 'lib/logstash/java_integration.rb', line 98 def &(other) # transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array intersection contract duped = Java::JavaUtil::LinkedHashSet.new(self) duped.retainAll(other) duped end |
#compact ⇒ Object
81 82 83 84 85 |
# File 'lib/logstash/java_integration.rb', line 81 def compact duped = Java::JavaUtil::ArrayList.new(self) duped.compact! duped end |
#compact! ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/logstash/java_integration.rb', line 87 def compact! size_before = self.size self.removeAll(java::util::Collections.singleton(nil)) if size_before == self.size nil else self end end |
#delete(o) ⇒ Object
support the Ruby Array delete method on a Java Collection
77 78 79 |
# File 'lib/logstash/java_integration.rb', line 77 def delete(o) self.removeAll([o]) ? o : block_given? ? yield : nil end |
#inspect ⇒ Object
113 114 115 |
# File 'lib/logstash/java_integration.rb', line 113 def inspect "<#{self.class.name}:#{self.hashCode} #{self.to_a(&:inspect)}>" end |
#is_a?(clazz) ⇒ Boolean
have Collections objects like ArrayList report is_a?(Array) == true
71 72 73 74 |
# File 'lib/logstash/java_integration.rb', line 71 def is_a?(clazz) return true if clazz == Array super end |
#|(other) ⇒ Object
support the Ruby union method on Java Collection
106 107 108 109 110 111 |
# File 'lib/logstash/java_integration.rb', line 106 def |(other) # transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array union contract duped = Java::JavaUtil::LinkedHashSet.new(self) duped.addAll(other) duped end |