Coverage Report - org.apache.onami.autobind.annotations.features.ImplementationBindingFeature
 
Classes in this File Line Coverage Branch Coverage Complexity
ImplementationBindingFeature
0%
0/11
0%
0/14
4.5
 
 1  
 package org.apache.onami.autobind.annotations.features;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 5  
  * contributor license agreements.  See the NOTICE file distributed with
 6  
  * this work for additional information regarding copyright ownership.
 7  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 8  
  * (the "License"); you may not use this file except in compliance with
 9  
  * the License.  You may obtain a copy of the License at
 10  
  *
 11  
  *  http://www.apache.org/licenses/LICENSE-2.0
 12  
  *
 13  
  * Unless required by applicable law or agreed to in writing, software
 14  
  * distributed under the License is distributed on an "AS IS" BASIS,
 15  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 16  
  * See the License for the specific language governing permissions and
 17  
  * limitations under the License.
 18  
  */
 19  
 
 20  
 import static java.lang.String.format;
 21  
 import static java.util.logging.Level.FINE;
 22  
 import static org.apache.onami.autobind.annotations.To.Type.IMPLEMENTATION;
 23  
 import static org.apache.onami.autobind.install.BindingStage.BINDING;
 24  
 import static org.apache.onami.autobind.install.BindingStage.IGNORE;
 25  
 
 26  
 import java.lang.annotation.Annotation;
 27  
 import java.util.Map;
 28  
 
 29  
 import javax.inject.Singleton;
 30  
 
 31  
 import org.apache.onami.autobind.annotations.Bind;
 32  
 import org.apache.onami.autobind.install.BindingStage;
 33  
 
 34  
 @Singleton
 35  0
 public class ImplementationBindingFeature
 36  
     extends AutoBindingFeature
 37  
 {
 38  
 
 39  
     @Override
 40  
     public BindingStage accept( Class<Object> annotatedClass, Map<String, Annotation> annotations )
 41  
     {
 42  0
         if ( annotations.containsKey( Bind.class.getName() ) )
 43  
         {
 44  0
             Bind annotation = (Bind) annotations.get( Bind.class.getName() );
 45  0
             if ( !annotation.multiple() && ( IMPLEMENTATION == annotation.to().value() ) )
 46  
             {
 47  0
                 return BINDING;
 48  
             }
 49  
         }
 50  0
         return IGNORE;
 51  
     }
 52  
 
 53  
     @Override
 54  
     public void process( final Class<Object> annotatedClass, final Map<String, Annotation> annotations )
 55  
     {
 56  0
         final boolean asSingleton =
 57  
             ( annotations.containsKey( com.google.inject.Singleton.class.getName() ) || annotations.containsKey( javax.inject.Singleton.class.getName() ) );
 58  
 
 59  0
         if ( _logger.isLoggable( FINE ) )
 60  
         {
 61  0
             _logger.fine( format( "Binding Class %s. Singleton? %s ", annotatedClass, asSingleton ) );
 62  
         }
 63  
 
 64  0
         bind( annotatedClass, null, ( asSingleton ? Singleton.class : null ) );
 65  0
     }
 66  
 
 67  
 }