@Override public boolean equals(final Object other) { final Object otherValue; if ( other instanceof IRubyObject ) { otherValue = unwrapObject((IRubyObject) other, NEVER); } else { otherValue = other; } if ( otherValue == NEVER ) return false; return getValue() == otherValue; // TODO seems weird why not equals ?! }
@Override public boolean equals(final Object other) { final Object otherValue; if ( other instanceof IRubyObject ) { otherValue = unwrapObject((IRubyObject) other, NEVER); } else { otherValue = other; } if ( otherValue == NEVER ) return false; return getValue() == otherValue; // TODO seems weird why not equals ?! }
@JRubyMethod(meta = true) public static IRubyObject wrap(final ThreadContext context, final IRubyObject self, final IRubyObject object) { final Object objectValue = unwrapObject(object, NEVER); if ( objectValue == NEVER ) return context.nil; return wrap(context.runtime, objectValue); }
@JRubyMethod(meta = true) public static IRubyObject wrap(final ThreadContext context, final IRubyObject self, final IRubyObject object) { final Object objectValue = unwrapObject(object, NEVER); if ( objectValue == NEVER ) return context.nil; return wrap(context.runtime, objectValue); }
private static RubyBoolean equals(final Ruby runtime, final Object thisValue, final IRubyObject other) { final Object otherValue = unwrapObject(other, NEVER); if ( otherValue == NEVER ) { // not a wrapped object return runtime.getFalse(); } if ( thisValue == null ) { return runtime.newBoolean(otherValue == null); } return runtime.newBoolean(thisValue.equals(otherValue)); }
private static RubyBoolean equals(final Ruby runtime, final Object thisValue, final IRubyObject other) { final Object otherValue = unwrapObject(other, NEVER); if ( otherValue == NEVER ) { // not a wrapped object return runtime.getFalse(); } if ( thisValue == null ) { return runtime.newBoolean(otherValue == null); } return runtime.newBoolean(thisValue.equals(otherValue)); }
@JRubyMethod(name = "equal?", required = 1) public IRubyObject same(final IRubyObject other) { final Ruby runtime = getRuntime(); final Object thisValue = getValue(); final Object otherValue = unwrapObject(other, NEVER); if ( otherValue == NEVER ) { // not a wrapped object return runtime.getFalse(); } if ( ! (other instanceof JavaObject) ) return runtime.getFalse(); return runtime.newBoolean(thisValue == otherValue); }
@JRubyMethod(name = "equal?", required = 1) public IRubyObject same(final IRubyObject other) { final Ruby runtime = getRuntime(); final Object thisValue = getValue(); final Object otherValue = unwrapObject(other, NEVER); if ( otherValue == NEVER ) { // not a wrapped object return runtime.getFalse(); } if ( ! (other instanceof JavaObject) ) return runtime.getFalse(); return runtime.newBoolean(thisValue == otherValue); }