/*
 * Copyright 2015, Kaazing Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY ERROR_TYPE_ID, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.kaazing.nuklei.tcp.internal.types.control;

import org.kaazing.nuklei.tcp.internal.types.Flyweight;

import uk.co.real_logic.agrona.BitUtil;
import uk.co.real_logic.agrona.DirectBuffer;

public final class UnbindFW extends Flyweight
{
    public static final int UNBIND_TYPE_ID = 0x00000002;

    private static final int FIELD_OFFSET_CORRELATION_ID = 0;
    private static final int FIELD_SIZE_CORRELATION_ID = BitUtil.SIZE_OF_LONG;

    private static final int FIELD_OFFSET_BINDING_REF = FIELD_OFFSET_CORRELATION_ID + FIELD_SIZE_CORRELATION_ID;
    private static final int FIELD_SIZE_BINDING_REF = BitUtil.SIZE_OF_LONG;

    public UnbindFW wrap(DirectBuffer buffer, int offset, int actingLimit)
    {
        super.wrap(buffer, offset);

        checkLimit(limit(), actingLimit);

        return this;
    }

    public int typeId()
    {
        return UNBIND_TYPE_ID;
    }

    public long correlationId()
    {
        return buffer().getLong(offset() + FIELD_OFFSET_CORRELATION_ID);
    }

    public long bindingRef()
    {
        return buffer().getLong(offset() + FIELD_OFFSET_BINDING_REF);
    }

    public int limit()
    {
        return offset() + FIELD_OFFSET_BINDING_REF + FIELD_SIZE_BINDING_REF;
    }

    @Override
    public String toString()
    {
        return String.format("[correlationId=%d, bindingRef=%d]", correlationId(), bindingRef());
    }
}

@@ -822,16 +822,68 @@
 tBuffer;
+%0Aimport uk.co.real_logic.agrona.MutableDirectBuffer;
 %0A%0Apublic
@@ -2066,11 +2066,739 @@
 );%0A    %7D
+%0A%0A    public static final class Builder extends Flyweight.Builder%3CUnbindFW%3E%0A    %7B%0A        public Builder()%0A        %7B%0A            super(new UnbindFW());%0A        %7D%0A%0A        @Override%0A        public Builder wrap(MutableDirectBuffer buffer, int offset, int maxLimit)%0A        %7B%0A            super.wrap(buffer, offset, maxLimit);%0A%0A            return this;%0A        %7D%0A%0A        public Builder correlationId(long correlationId)%0A        %7B%0A            buffer().putLong(offset() + FIELD_OFFSET_CORRELATION_ID, correlationId);%0A            return this;%0A        %7D%0A%0A        public Builder bindingRef(long bindingRef)%0A        %7B%0A            buffer().putLong(offset() + FIELD_OFFSET_BINDING_REF, bindingRef);%0A            return this;%0A        %7D%0A    %7D
 %0A%7D%0A

Add missing builder for completeness