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

org.openlca.proto.io.server.AboutService Maven / Gradle / Ivy

package org.openlca.proto.io.server;

import java.util.Objects;

import com.google.protobuf.Empty;
import io.grpc.stub.StreamObserver;
import org.openlca.core.database.IDatabase;
import org.openlca.proto.grpc.AboutResponse;
import org.openlca.proto.grpc.AboutServiceGrpc;
import org.openlca.util.Strings;

public class AboutService extends AboutServiceGrpc.AboutServiceImplBase {

  public static final int VERSION = 2;
  public static final int MIN_SUPPORTED_VERSION = 2;
  private final IDatabase db;

  public AboutService(IDatabase db) {
    this.db = Objects.requireNonNull(db);
  }

  @Override
  public void about(Empty req, StreamObserver resp) {
    var about = AboutResponse.newBuilder()
      .setVersion(VERSION)
      .setMinSupportedVersion(MIN_SUPPORTED_VERSION)
      .setDatabase(Strings.orEmpty(db.getName()))
      .build();
    resp.onNext(about);
    resp.onCompleted();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy