Coverage Report - com.mattunderscore.filter.contentnegotiation.parser.CrossProduct
 
Classes in this File Line Coverage Branch Coverage Complexity
CrossProduct
100%
7/7
N/A
1
 
 1  
 /* Copyright © 2012 Matthew Champion
 2  
 All rights reserved.
 3  
 
 4  
 Redistribution and use in source and binary forms, with or without
 5  
 modification, are permitted provided that the following conditions are met:
 6  
     * Redistributions of source code must retain the above copyright
 7  
       notice, this list of conditions and the following disclaimer.
 8  
     * Redistributions in binary form must reproduce the above copyright
 9  
       notice, this list of conditions and the following disclaimer in the
 10  
       documentation and/or other materials provided with the distribution.
 11  
     * Neither the name of mattunderscore.com nor the
 12  
       names of its contributors may be used to endorse or promote products
 13  
       derived from this software without specific prior written permission.
 14  
 
 15  
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 16  
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 17  
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 18  
 DISCLAIMED. IN NO EVENT SHALL MATTHEW CHAMPION BE LIABLE FOR ANY
 19  
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 20  
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 21  
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 22  
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 23  
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 24  
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 25  
 
 26  
 package com.mattunderscore.filter.contentnegotiation.parser;
 27  
 
 28  
 import com.mattunderscore.http.headers.Qualified;
 29  
 
 30  
 /**
 31  
  * Cross product used to combine the quality and quality of source values for a
 32  
  * variant.
 33  
  * 
 34  
  * @author Matt Champion
 35  
  * @since 0.0.13
 36  
  */
 37  
 public class CrossProduct implements Qualified
 38  
 {
 39  
 
 40  
     private final Qualified q0;
 41  
     private final Qualified q1;
 42  
     private final Variant variant;
 43  
 
 44  
     public CrossProduct(Qualified q0, Qualified q1, Variant variant)
 45  20
     {
 46  20
         this.q0 = q0;
 47  20
         this.q1 = q1;
 48  20
         this.variant = variant;
 49  20
     }
 50  
 
 51  
     @Override
 52  
     public double getQualifier()
 53  
     {
 54  28
         return q0.getQualifier() * q1.getQualifier();
 55  
     }
 56  
 
 57  
     /**
 58  
      * Returns the server's variant associated with the cross product. 
 59  
      * @return Variant of cross product
 60  
      */
 61  
     public Variant getVariant()
 62  
     {
 63  12
         return variant;
 64  
     }
 65  
 }