LCOV - code coverage report
Current view: top level - index/query - TimestampRangePredicate.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 4 6 66.7 %
Date: 2022-11-19 15:00:39 Functions: 3 3 100.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.index.query;
      16             : 
      17             : import com.google.gerrit.index.SchemaFieldDefs.SchemaField;
      18             : import com.google.gerrit.json.JavaSqlTimestampHelper;
      19             : import java.sql.Timestamp;
      20             : import java.time.Instant;
      21             : 
      22             : // TODO: Migrate this to IntegerRangePredicate
      23             : public abstract class TimestampRangePredicate<I> extends IndexPredicate<I> {
      24             :   protected static Instant parse(String value) throws QueryParseException {
      25             :     try {
      26           4 :       return JavaSqlTimestampHelper.parseTimestamp(value).toInstant();
      27           0 :     } catch (IllegalArgumentException e) {
      28             :       // parseTimestamp's errors are specific and helpful, so preserve them.
      29           0 :       throw new QueryParseException(e.getMessage(), e);
      30             :     }
      31             :   }
      32             : 
      33             :   protected TimestampRangePredicate(SchemaField<I, Timestamp> def, String name, String value) {
      34           5 :     super(def, name, value);
      35           5 :   }
      36             : 
      37             :   protected Timestamp getValueTimestamp(I object) {
      38           5 :     return (Timestamp) this.getField().get(object);
      39             :   }
      40             : 
      41             :   public abstract Instant getMinTimestamp();
      42             : 
      43             :   public abstract Instant getMaxTimestamp();
      44             : }

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