LCOV - code coverage report
Current view: top level - extensions/config - FactoryModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 3 3 100.0 %
Date: 2022-11-19 15:00:39 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2009 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.config;
      16             : 
      17             : import com.google.inject.AbstractModule;
      18             : import com.google.inject.assistedinject.FactoryModuleBuilder;
      19             : 
      20         154 : public abstract class FactoryModule extends AbstractModule {
      21             :   /**
      22             :    * Register an assisted injection factory.
      23             :    *
      24             :    * <p>This function provides an automatic way to define a factory that creates a concrete type
      25             :    * through assisted injection. For example to configure the following assisted injection case:
      26             :    *
      27             :    * <pre>
      28             :    * public class Foo {
      29             :    *   public interface Factory {
      30             :    *     Foo create(int a);
      31             :    *   }
      32             :    *   &#064;Inject
      33             :    *   Foo(Logger log, @Assisted int a) {...}
      34             :    * }
      35             :    * </pre>
      36             :    *
      37             :    * Just pass {@code Foo.Factory.class} to this method. The factory will be generated to return its
      38             :    * one return type as declared in the creation method.
      39             :    *
      40             :    * @param factory interface which specifies the bean factory method.
      41             :    */
      42             :   protected void factory(Class<?> factory) {
      43         153 :     install(new FactoryModuleBuilder().build(factory));
      44         153 :   }
      45             : }

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