All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.wjybxx.btreecodec.fsm.StackStateMachineTaskCodec Maven / Gradle / Ivy

The newest version!
package cn.wjybxx.btreecodec.fsm;

import cn.wjybxx.btree.Task;
import cn.wjybxx.btree.fsm.StackStateMachineTask;
import cn.wjybxx.dson.WireType;
import cn.wjybxx.dson.text.NumberStyle;
import cn.wjybxx.dson.text.ObjectStyle;
import cn.wjybxx.dson.text.StringStyle;
import cn.wjybxx.dsoncodec.AbstractDsonCodec;
import cn.wjybxx.dsoncodec.DsonObjectReader;
import cn.wjybxx.dsoncodec.DsonObjectWriter;
import cn.wjybxx.dsoncodec.TypeInfo;
import javax.annotation.Nonnull;
import javax.annotation.processing.Generated;

@SuppressWarnings({"unchecked", "rawtypes", "unused"})
@Generated("cn.wjybxx.dsonapt.CodecProcessor")
public final class StackStateMachineTaskCodec extends AbstractDsonCodec {
    public static final TypeInfo types_guard = TypeInfo.of(Task.class, Object.class);

    public static final TypeInfo types_flags = TypeInfo.of(int.class);

    public static final TypeInfo types_child = TypeInfo.of(Task.class, Object.class);

    public static final TypeInfo types_name = TypeInfo.of(String.class);

    public static final TypeInfo types_initState = TypeInfo.of(Task.class, Object.class);

    public static final TypeInfo types_initStateProps = TypeInfo.of(Object.class);

    public static final TypeInfo types_undoQueueCapacity = TypeInfo.of(int.class);

    public static final TypeInfo types_redoQueueCapacity = TypeInfo.of(int.class);

    public static final String names_guard = "guard";

    public static final String names_flags = "flags";

    public static final String names_child = "child";

    public static final String names_name = "name";

    public static final String names_initState = "initState";

    public static final String names_initStateProps = "initStateProps";

    public static final String names_undoQueueCapacity = "undoQueueCapacity";

    public static final String names_redoQueueCapacity = "redoQueueCapacity";

    @Override
    @Nonnull
    public Class getEncoderClass() {
        return StackStateMachineTask.class;
    }

    @Override
    public void writeFields(DsonObjectWriter writer, StackStateMachineTask instance,
            TypeInfo typeInfo, ObjectStyle style) {
        writer.writeObject(names_guard, instance.getGuard(), types_guard, null);
        writer.writeInt(names_flags, instance.getFlags(), WireType.VARINT, NumberStyle.SIMPLE);
        writer.writeObject(names_child, instance.getChild(), types_child, null);
        writer.writeString(names_name, instance.getName(), StringStyle.AUTO);
        writer.writeObject(names_initState, instance.getInitState(), types_initState, null);
        writer.writeObject(names_initStateProps, instance.getInitStateProps(), types_initStateProps, null);
        writer.writeInt(names_undoQueueCapacity, instance.getUndoQueueCapacity(), WireType.VARINT, NumberStyle.SIMPLE);
        writer.writeInt(names_redoQueueCapacity, instance.getRedoQueueCapacity(), WireType.VARINT, NumberStyle.SIMPLE);
    }

    @Override
    protected StackStateMachineTask newInstance(DsonObjectReader reader, TypeInfo typeInfo) {
        return new StackStateMachineTask();
    }

    @Override
    public void readFields(DsonObjectReader reader, StackStateMachineTask instance,
            TypeInfo typeInfo) {
        instance.setGuard(reader.readObject(names_guard, types_guard, null));
        instance.setFlags(reader.readInt(names_flags));
        instance.setChild(reader.readObject(names_child, types_child, null));
        instance.setName(reader.readString(names_name));
        instance.setInitState(reader.readObject(names_initState, types_initState, null));
        instance.setInitStateProps(reader.readObject(names_initStateProps, types_initStateProps, null));
        instance.setUndoQueueCapacity(reader.readInt(names_undoQueueCapacity));
        instance.setRedoQueueCapacity(reader.readInt(names_redoQueueCapacity));
    }
}