Class: javajava::lang::Enum

Inherits:
Object show all
Defined in:
lib/jactive_support/java_ext/enum.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_value_of(value) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/jactive_support/java_ext/enum.rb', line 2

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

Instance Method Details

#===(other) ⇒ Object



15
16
17
18
# File 'lib/jactive_support/java_ext/enum.rb', line 15

def ===(other)
  other = other.to_s
  self.name == other || self.name == other.camelize
end