LCOV - code coverage report
Current view: top level - entities/converter - PatchSetApprovalKeyProtoConverter.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 15 16 93.8 %
Date: 2022-11-19 15:00:39 Functions: 4 5 80.0 %

          Line data    Source code
       1             : // Copyright (C) 2018 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.entities.converter;
      16             : 
      17             : import com.google.errorprone.annotations.Immutable;
      18             : import com.google.gerrit.entities.Account;
      19             : import com.google.gerrit.entities.LabelId;
      20             : import com.google.gerrit.entities.PatchSet;
      21             : import com.google.gerrit.entities.PatchSetApproval;
      22             : import com.google.gerrit.proto.Entities;
      23             : import com.google.protobuf.Parser;
      24             : 
      25         104 : @Immutable
      26         104 : public enum PatchSetApprovalKeyProtoConverter
      27             :     implements ProtoConverter<Entities.PatchSetApproval_Key, PatchSetApproval.Key> {
      28         104 :   INSTANCE;
      29             : 
      30         104 :   private final ProtoConverter<Entities.PatchSet_Id, PatchSet.Id> patchSetIdConverter =
      31             :       PatchSetIdProtoConverter.INSTANCE;
      32         104 :   private final ProtoConverter<Entities.Account_Id, Account.Id> accountIdConverter =
      33             :       AccountIdProtoConverter.INSTANCE;
      34         104 :   private final ProtoConverter<Entities.LabelId, LabelId> labelIdConverter =
      35             :       LabelIdProtoConverter.INSTANCE;
      36             : 
      37             :   @Override
      38             :   public Entities.PatchSetApproval_Key toProto(PatchSetApproval.Key key) {
      39          69 :     return Entities.PatchSetApproval_Key.newBuilder()
      40          69 :         .setPatchSetId(patchSetIdConverter.toProto(key.patchSetId()))
      41          69 :         .setAccountId(accountIdConverter.toProto(key.accountId()))
      42          69 :         .setLabelId(labelIdConverter.toProto(key.labelId()))
      43          69 :         .build();
      44             :   }
      45             : 
      46             :   @Override
      47             :   public PatchSetApproval.Key fromProto(Entities.PatchSetApproval_Key proto) {
      48          67 :     return PatchSetApproval.key(
      49          67 :         patchSetIdConverter.fromProto(proto.getPatchSetId()),
      50          67 :         accountIdConverter.fromProto(proto.getAccountId()),
      51          67 :         labelIdConverter.fromProto(proto.getLabelId()));
      52             :   }
      53             : 
      54             :   @Override
      55             :   public Parser<Entities.PatchSetApproval_Key> getParser() {
      56           0 :     return Entities.PatchSetApproval_Key.parser();
      57             :   }
      58             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750