// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package org.wpilib.math.kinematics.struct;

import java.nio.ByteBuffer;
import org.wpilib.math.kinematics.MecanumDriveWheelAccelerations;
import org.wpilib.util.struct.Struct;

public class MecanumDriveWheelAccelerationsStruct
    implements Struct<MecanumDriveWheelAccelerations> {
  @Override
  public Class<MecanumDriveWheelAccelerations> getTypeClass() {
    return MecanumDriveWheelAccelerations.class;
  }

  @Override
  public String getTypeName() {
    return "MecanumDriveWheelAccelerations";
  }

  @Override
  public int getSize() {
    return DOUBLE_SIZE * 4;
  }

  @Override
  public String getSchema() {
    return "double front_left;double front_right;double rear_left;double rear_right";
  }

  @Override
  public MecanumDriveWheelAccelerations unpack(ByteBuffer bb) {
    double frontLeft = bb.getDouble();
    double frontRight = bb.getDouble();
    double rearLeft = bb.getDouble();
    double rearRight = bb.getDouble();
    return new MecanumDriveWheelAccelerations(frontLeft, frontRight, rearLeft, rearRight);
  }

  @Override
  public void pack(ByteBuffer bb, MecanumDriveWheelAccelerations value) {
    bb.putDouble(value.frontLeft);
    bb.putDouble(value.frontRight);
    bb.putDouble(value.rearLeft);
    bb.putDouble(value.rearRight);
  }
}
