Sha256: b3add8349aa10bbc42acda40fc117f6cc3bdedc674c87717dffb1594f41e32f5

Contents?: true

Size: 624 Bytes

Versions: 10

Compression:

Stored size: 624 Bytes

Contents

class java::lang::Enum
  def self.find_value_of(value)
    value = value.to_s
    camel_name = value.camelize
    if(camel_name == value)
      self.valueOf(value)
    else
      ret = self.java_class.to_java.getEnumConstants.find {|e| e.name == value || e.name == camel_name}
      #raise java::lang::IllegalArgumentException.new("No enum const class #{java_class.name}.#{value}") unless ret
      self.valueOf(value) unless ret # Above does not throw the exception the same way as java code
      ret
    end
  end
  
  def ===(other)
    other = other.to_s
    self.name == other || self.name == other.camelize
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jactive_support-2.1.2 lib/jactive_support/java_ext/enum.rb
jactive_support-3.0.0 lib/jactive_support/java_ext/enum.rb
jactive_support-3.0.0.pre2 lib/jactive_support/java_ext/enum.rb
jactive_support-3.0.0.pre1 lib/jactive_support/java_ext/enum.rb
jactive_support-2.1.1 lib/jactive_support/java_ext/enum.rb
jactive_support-2.1.0 lib/jactive_support/java_ext/enum.rb
jactive_support-2.0.0 lib/jactive_support/java_ext/enum.rb
jactive_support-1.0.2 lib/jactive_support/java_ext/enum.rb
jactive_support-1.0.1-universal-java-1.6 lib/jactive_support/java_ext/enum.rb
jactive_support-1.0.0-universal-java-1.6 lib/jactive_support/java_ext/enum.rb