Module: JMX::JavaTypeAware
- Included in:
- Attribute, DynamicMBean, Operation, Parameter
- Defined in:
- lib/dynamic_mbean.rb
Overview
Module that is used to bridge java to ruby and ruby to java types.
Constant Summary collapse
- SIMPLE_TYPES =
Current list of types we understand If it’s not in this list we are assuming that we are going to convert to a java.object
{ :boolean => ['java.lang.Boolean', lambda {|param| param}], :byte => ['java.lang.Byte', lambda {|param| param.to_i}], :int => ['java.lang.Integer', lambda {|param| param.to_i}], :long => ['java.lang.Long', lambda {|param| param.to_i}], :float => ['java.lang.Float', lambda {|param| param.to_f}], :double => ['java.lang.Double', lambda {|param| param.to_f}], :list => ['java.util.ArrayList', lambda {|param| param.to_a}], :map => ['java.util.HashMap', lambda {|param| param}], :set => ['java.util.HashSet', lambda {|param| param}], :string => ['java.lang.String', lambda {|param| param.to_s}], :void => ['java.lang.Void', lambda {|param| nil}] }
Instance Method Summary collapse
- #to_java_type(type_name) ⇒ Object
-
#to_ruby(type_name) ⇒ Object
TODO: I’m not sure this is strictly needed, but funky things can happen if you are expecting your attributes (from the ruby side) to be ruby types and they are java types.
Instance Method Details
#to_java_type(type_name) ⇒ Object
29 30 31 |
# File 'lib/dynamic_mbean.rb', line 29 def to_java_type(type_name) SIMPLE_TYPES[type_name][0] || type_name end |
#to_ruby(type_name) ⇒ Object
TODO: I’m not sure this is strictly needed, but funky things can happen if you are expecting your attributes (from the ruby side) to be ruby types and they are java types.
34 35 36 |
# File 'lib/dynamic_mbean.rb', line 34 def to_ruby(type_name) SIMPLE_TYPES[type_name][1] || lambda {|param| param} end |