Skip to content

Commit 5e31bb3

Browse files
committed
Make constructors protected to simplify the single entry point
Makes constructors of MessagePacker and MessageUnpacker protected so that all users use factory methods of MessagePack interface. This removes duplication of API and make it easy to understand.
1 parent bdb2c2a commit 5e31bb3

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

msgpack-core/src/main/java/org/msgpack/core/MessageBufferPacker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
public class MessageBufferPacker
2929
extends MessagePacker
3030
{
31-
public MessageBufferPacker(MessagePack.PackerConfig config)
31+
protected MessageBufferPacker(MessagePack.PackerConfig config)
3232
{
3333
this(new ArrayBufferOutput(), config);
3434
}
3535

36-
public MessageBufferPacker(ArrayBufferOutput out, MessagePack.PackerConfig config)
36+
protected MessageBufferPacker(ArrayBufferOutput out, MessagePack.PackerConfig config)
3737
{
3838
super(out, config);
3939
}

msgpack-core/src/main/java/org/msgpack/core/MessagePacker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ public class MessagePacker
105105
private CharsetEncoder encoder;
106106

107107
/**
108-
* Create an MessagePacker that outputs the packed data to the given {@link org.msgpack.core.buffer.MessageBufferOutput}
108+
* Create an MessagePacker that outputs the packed data to the given {@link org.msgpack.core.buffer.MessageBufferOutput}.
109+
* This method is available for subclasses to override. Use MessagePack.PackerConfig.newPacker method to instanciate this implementation.
109110
*
110111
* @param out MessageBufferOutput. Use {@link org.msgpack.core.buffer.OutputStreamBufferOutput}, {@link org.msgpack.core.buffer.ChannelBufferOutput} or
111112
* your own implementation of {@link org.msgpack.core.buffer.MessageBufferOutput} interface.
112113
*/
113-
public MessagePacker(MessageBufferOutput out, MessagePack.PackerConfig config)
114+
protected MessagePacker(MessageBufferOutput out, MessagePack.PackerConfig config)
114115
{
115116
this.out = checkNotNull(out, "MessageBufferOutput is null");
116117
// We must copy the configuration parameters here since the config object is mutable

msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ public class MessageUnpacker
122122
private CharBuffer decodeBuffer;
123123

124124
/**
125-
* Create an MessageUnpacker that reads data from the given MessageBufferInput
125+
* Create an MessageUnpacker that reads data from the given MessageBufferInput.
126+
* This method is available for subclasses to override. Use MessagePack.UnpackerConfig.newUnpacker method to instanciate this implementation.
126127
*
127128
* @param in
128129
*/
129-
public MessageUnpacker(MessageBufferInput in, MessagePack.UnpackerConfig config)
130+
protected MessageUnpacker(MessageBufferInput in, MessagePack.UnpackerConfig config)
130131
{
131132
this.in = checkNotNull(in, "MessageBufferInput is null");
132133
// We need to copy the configuration parameters since the config object is mutable

0 commit comments

Comments
 (0)