BJ-76: Add byteStack, double value

This commit is contained in:
Pavel Popov 2017-01-31 18:39:53 +03:00
parent a8d3f6c2d9
commit d73a1f12ad
3 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,59 @@
package com.rbkmoney.kebab;
/**
* Created by vpankrashkin on 31.01.17.
*/
public class ByteStack {
private byte[] stack;
private int size;
public ByteStack(final int initialCapacity) {
if (initialCapacity <= 0) {
throw new IllegalArgumentException("Size must be > 0");
}
this.stack = new byte[initialCapacity];
this.size = 0;
}
public ByteStack() {
this(10);
}
public final void push(final byte item) {
if (size == stack.length) {
byte[] newStack = new byte[size << 1];
for (int i = 0; i < stack.length; ++i) {
newStack[i] = stack[i];
}
stack = newStack;
}
stack[size++] = item;
}
public final byte pop() {
if (size == 0) {
throw new RuntimeException("No more elements");
}
return stack[--size];
}
public final byte peek() {
if (size == 0) {
throw new RuntimeException("No more elements");
}
return stack[size];
}
public final int size() {
return size;
}
public final boolean isEmpty() {
return size == 0;
}
}

View File

@ -64,6 +64,9 @@ public class TBaseSerializer implements Serializer<TBase> {
case LONG:
out.value((long) object);
break;
case DOUBLE:
out.value((double) object);
break;
case LIST:
write(out, (List) object, (ListMetaData) fieldValueMetaData);
break;

View File

@ -4,7 +4,6 @@ import com.rbkmoney.kebab.test.Fail;
import com.rbkmoney.kebab.test.Ids;
import com.rbkmoney.kebab.test.Status;
import com.rbkmoney.kebab.test.TestObject;
import com.rbkmoney.kebab.thrift.ThriftElement;
import org.junit.Test;
import java.util.*;