refactor FixedSizeCompressedObjectStrategy

This commit is contained in:
Xavier Léauté 2014-08-06 16:13:39 -07:00
parent 991e1828b0
commit 6fa611c262
3 changed files with 12 additions and 22 deletions

View File

@ -35,8 +35,6 @@ public class CompressedFloatBufferObjectStrategy extends FixedSizeCompressedObje
return new CompressedFloatBufferObjectStrategy(order, compression, sizePer); return new CompressedFloatBufferObjectStrategy(order, compression, sizePer);
} }
private final int sizePer;
private CompressedFloatBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer) private CompressedFloatBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer)
{ {
super( super(
@ -67,14 +65,8 @@ public class CompressedFloatBufferObjectStrategy extends FixedSizeCompressedObje
return into.asFloatBuffer().put(from); return into.asFloatBuffer().put(from);
} }
}, },
compression compression,
sizePer
); );
this.sizePer = sizePer;
}
@Override
public int getSize()
{
return sizePer;
} }
} }

View File

@ -35,8 +35,6 @@ public class CompressedLongBufferObjectStrategy extends FixedSizeCompressedObjec
return new CompressedLongBufferObjectStrategy(order, compression, sizePer); return new CompressedLongBufferObjectStrategy(order, compression, sizePer);
} }
private final int sizePer;
private CompressedLongBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer) private CompressedLongBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer)
{ {
super( super(
@ -67,14 +65,8 @@ public class CompressedLongBufferObjectStrategy extends FixedSizeCompressedObjec
return into.asLongBuffer().put(from); return into.asLongBuffer().put(from);
} }
}, },
compression compression,
sizePer
); );
this.sizePer = sizePer;
}
@Override
public int getSize()
{
return sizePer;
} }
} }

View File

@ -25,16 +25,22 @@ import java.nio.ByteOrder;
public abstract class FixedSizeCompressedObjectStrategy<T extends Buffer> extends CompressedObjectStrategy<T> public abstract class FixedSizeCompressedObjectStrategy<T extends Buffer> extends CompressedObjectStrategy<T>
{ {
private final int sizePer;
protected FixedSizeCompressedObjectStrategy( protected FixedSizeCompressedObjectStrategy(
ByteOrder order, ByteOrder order,
BufferConverter<T> converter, BufferConverter<T> converter,
CompressionStrategy compression CompressionStrategy compression,
int sizePer
) )
{ {
super(order, converter, compression); super(order, converter, compression);
this.sizePer = sizePer;
} }
public abstract int getSize(); public int getSize() {
return sizePer;
}
@Override @Override
protected ByteBuffer bufferFor(T val) protected ByteBuffer bufferFor(T val)