LCOV - code coverage report
Current view: top level - extensions/restapi - CacheControl.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 17 18 94.4 %
Date: 2022-11-19 15:00:39 Functions: 9 10 90.0 %

          Line data    Source code
       1             : // Copyright (C) 2013 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.extensions.restapi;
      16             : 
      17             : import java.util.concurrent.TimeUnit;
      18             : 
      19             : public class CacheControl {
      20             : 
      21         155 :   public enum Type {
      22         155 :     @SuppressWarnings("hiding")
      23             :     NONE,
      24         155 :     PUBLIC,
      25         155 :     PRIVATE
      26             :   }
      27             : 
      28         155 :   public static final CacheControl NONE = new CacheControl(Type.NONE, 0, null);
      29             : 
      30             :   public static CacheControl PUBLIC(long age, TimeUnit unit) {
      31           0 :     return new CacheControl(Type.PUBLIC, age, unit);
      32             :   }
      33             : 
      34             :   public static CacheControl PRIVATE(long age, TimeUnit unit) {
      35         152 :     return new CacheControl(Type.PRIVATE, age, unit);
      36             :   }
      37             : 
      38             :   private final Type type;
      39             :   private final long age;
      40             :   private final TimeUnit unit;
      41             :   private boolean mustRevalidate;
      42             : 
      43         155 :   private CacheControl(Type type, long age, TimeUnit unit) {
      44         155 :     this.type = type;
      45         155 :     this.age = age;
      46         155 :     this.unit = unit;
      47         155 :   }
      48             : 
      49             :   public Type getType() {
      50          19 :     return type;
      51             :   }
      52             : 
      53             :   public long getAge() {
      54           7 :     return age;
      55             :   }
      56             : 
      57             :   public TimeUnit getUnit() {
      58           7 :     return unit;
      59             :   }
      60             : 
      61             :   public boolean isMustRevalidate() {
      62           7 :     return mustRevalidate;
      63             :   }
      64             : 
      65             :   public CacheControl setMustRevalidate() {
      66          68 :     mustRevalidate = true;
      67          68 :     return this;
      68             :   }
      69             : }

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