public static class Builder extends PropsBuilder<Builder> { private final RiakPB.RpbSetBucketReq.Builder reqBuilder = RiakPB.RpbSetBucketReq.newBuilder(); private final Namespace namespace; /** * Constructs a builder for a StoreBucketPropsOperation. * * @param namespace The namespace in Riak. */ public Builder(Namespace namespace) { if (namespace == null) { throw new IllegalArgumentException("Namespace cannot be null"); } reqBuilder.setBucket(ByteString.copyFrom(namespace.getBucketName().unsafeGetValue())); reqBuilder.setType(ByteString.copyFrom(namespace.getBucketType().unsafeGetValue())); this.namespace = namespace; } @Override protected Builder self() { return this; } public StoreBucketPropsOperation build() { reqBuilder.setProps(propsBuilder); return new StoreBucketPropsOperation(this); } }
@Override protected RiakMessage createChannelMessage() { RiakPB.RpbSetBucketReq req = reqBuilder.build(); return new RiakMessage(RiakMessageCodes.MSG_SetBucketReq, req.toByteArray()); }