CLEANUP: Remove unused TimeBiValue

Fixes #7920
This commit is contained in:
Armin 2017-08-06 10:01:13 +02:00 committed by Armin Braun
parent 0ea2be9732
commit 8153411c15
3 changed files with 0 additions and 61 deletions

View file

@ -14,7 +14,6 @@ import org.jruby.RubySymbol;
import org.logstash.ackedqueue.Queueable;
import org.logstash.bivalues.BiValues;
import org.logstash.bivalues.NullBiValue;
import org.logstash.bivalues.TimeBiValue;
import org.logstash.bivalues.TimestampBiValue;
import org.logstash.ext.JrubyTimestampExtLibrary;
@ -311,8 +310,6 @@ public final class Event implements Cloneable, Queueable {
return new Timestamp((String) o);
} else if (o instanceof RubyString) {
return new Timestamp(o.toString());
} else if (o instanceof TimeBiValue) {
return new Timestamp(((TimeBiValue) o).javaValue());
} else if (o instanceof JrubyTimestampExtLibrary.RubyTimestamp) {
return ((JrubyTimestampExtLibrary.RubyTimestamp) o).getTimestamp();
} else if (o instanceof Timestamp) {

View file

@ -1,37 +0,0 @@
package org.logstash.bivalues;
import org.joda.time.DateTime;
import org.jruby.Ruby;
import org.jruby.RubyTime;
import java.io.ObjectStreamException;
public class TimeBiValue extends BiValue<RubyTime, DateTime> {
public TimeBiValue(RubyTime rubyValue) {
this.rubyValue = rubyValue;
javaValue = null;
}
public TimeBiValue(DateTime javaValue) {
this.javaValue = javaValue;
rubyValue = null;
}
private TimeBiValue() {
}
protected void addRuby(Ruby runtime) {
rubyValue = RubyTime.newTime(runtime, javaValue);
}
protected void addJava() {
javaValue = rubyValue.getDateTime();
}
// Called when object is to be serialized on a stream to allow the object to substitute a proxy for itself.
private Object writeReplace() throws ObjectStreamException {
return newProxy(this);
}
}

View file

@ -6,14 +6,12 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.joda.time.DateTime;
import org.jruby.RubyBignum;
import org.jruby.RubyBoolean;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
import org.jruby.RubyInteger;
import org.jruby.RubySymbol;
import org.jruby.RubyTime;
import org.jruby.ext.bigdecimal.RubyBigDecimal;
import org.junit.Test;
import org.logstash.TestBase;
@ -131,25 +129,6 @@ public class BiValueTest extends TestBase {
assertEquals(ruby.getNil(), subject.rubyValue(ruby));
}
@Test
public void testTimeBiValueFromRuby() {
DateTime t = DateTime.now();
RubyTime now = RubyTime.newTime(ruby, t);
TimeBiValue subject = new TimeBiValue(now);
assertTrue(subject.hasRubyValue());
assertFalse(subject.hasJavaValue());
assertEquals(t, subject.javaValue());
}
@Test
public void testTimeBiValueFromJava() {
DateTime t = DateTime.now();
TimeBiValue subject = new TimeBiValue(t);
assertFalse(subject.hasRubyValue());
assertTrue(subject.hasJavaValue());
assertEquals(RubyTime.newTime(ruby, t), subject.rubyValue(ruby));
}
@Test
public void testBigIntegerBiValueFromRuby() {
BigInteger s = BigInteger.valueOf(12345678L);