@Override public boolean equals(Object other) { Object myValue = getValue(); Object otherValue = other; if (other instanceof IRubyObject) { otherValue = getWrappedObject((IRubyObject)other, NEVER); } if (otherValue == NEVER) { // not a wrapped object return false; } return myValue == otherValue; }
@Override public boolean equals(Object other) { Object myValue = getValue(); Object otherValue = other; if (other instanceof IRubyObject) { otherValue = getWrappedObject((IRubyObject)other, NEVER); } if (otherValue == NEVER) { // not a wrapped object return false; } return myValue == otherValue; }
@JRubyMethod(meta = true) public static IRubyObject wrap(ThreadContext context, IRubyObject self, IRubyObject object) { Ruby runtime = context.runtime; Object obj = getWrappedObject(object, NEVER); if (obj == NEVER) return runtime.getNil(); return wrap(runtime, obj); }
@JRubyMethod(meta = true) public static IRubyObject wrap(ThreadContext context, IRubyObject self, IRubyObject object) { Ruby runtime = context.runtime; Object obj = getWrappedObject(object, NEVER); if (obj == NEVER) return runtime.getNil(); return wrap(runtime, obj); }
private static IRubyObject opEqualShared(Object myValue, IRubyObject other) { Ruby runtime = other.getRuntime(); Object otherValue = getWrappedObject(other, NEVER); if (other == NEVER) { // not a wrapped object return runtime.getFalse(); } if (myValue == null && otherValue == null) { return runtime.getTrue(); } return runtime.newBoolean(myValue.equals(otherValue)); }
private static IRubyObject opEqualShared(Object myValue, IRubyObject other) { Ruby runtime = other.getRuntime(); Object otherValue = getWrappedObject(other, NEVER); if (other == NEVER) { // not a wrapped object return runtime.getFalse(); } if (myValue == null && otherValue == null) { return runtime.getTrue(); } return runtime.newBoolean(myValue.equals(otherValue)); }
@JRubyMethod(name = "equal?", required = 1) public IRubyObject same(IRubyObject other) { Ruby runtime = getRuntime(); Object myValue = getValue(); Object otherValue = getWrappedObject(other, NEVER); if (other == NEVER) { // not a wrapped object return runtime.getFalse(); } if (myValue == null && otherValue == null) { return getRuntime().getTrue(); } if (!(other instanceof JavaObject)) return runtime.getFalse(); boolean isSame = getValue() == ((JavaObject) other).getValue(); return isSame ? getRuntime().getTrue() : getRuntime().getFalse(); }
@JRubyMethod(name = "equal?", required = 1) public IRubyObject same(IRubyObject other) { Ruby runtime = getRuntime(); Object myValue = getValue(); Object otherValue = getWrappedObject(other, NEVER); if (other == NEVER) { // not a wrapped object return runtime.getFalse(); } if (myValue == null && otherValue == null) { return getRuntime().getTrue(); } if (!(other instanceof JavaObject)) return runtime.getFalse(); boolean isSame = getValue() == ((JavaObject) other).getValue(); return isSame ? getRuntime().getTrue() : getRuntime().getFalse(); }