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

com.github.moaxcp.x11client.protocol.randr.RefreshRates Maven / Gradle / Ivy

There is a newer version: 0.18.2
Show newest version
package com.github.moaxcp.x11client.protocol.randr;

import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XStruct;
import java.io.IOException;
import java.lang.Override;
import java.lang.Short;
import java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

@Value
@Builder
public class RefreshRates implements XStruct {
  @NonNull
  private List rates;

  public static RefreshRates readRefreshRates(X11Input in) throws IOException {
    short nRates = in.readCard16();
    List rates = in.readCard16(Short.toUnsignedInt(nRates));
    RefreshRates.RefreshRatesBuilder javaBuilder = RefreshRates.builder();
    javaBuilder.rates(rates);
    return javaBuilder.build();
  }

  @Override
  public void write(X11Output out) throws IOException {
    short nRates = (short) rates.size();
    out.writeCard16(nRates);
    out.writeCard16(rates);
  }

  @Override
  public int getSize() {
    return 2 + 2 * rates.size();
  }

  public static class RefreshRatesBuilder {
    public int getSize() {
      return 2 + 2 * rates.size();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy