Coverage Report - org.apache.commons.functor.core.NoOp
 
Classes in this File Line Coverage Branch Coverage Complexity
NoOp
83%
10/12
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.functor.core;
 18  
 
 19  
 import java.io.Serializable;
 20  
 
 21  
 import org.apache.commons.functor.BinaryProcedure;
 22  
 import org.apache.commons.functor.Procedure;
 23  
 import org.apache.commons.functor.UnaryProcedure;
 24  
 
 25  
 /**
 26  
  * A procedure that does nothing at all.
 27  
  * <p>
 28  
  * Note that this class implements {@link Procedure},
 29  
  * {@link UnaryProcedure}, and {@link BinaryProcedure}.
 30  
  * </p>
 31  
  * @version $Revision: 1156349 $ $Date: 2011-08-10 22:21:14 +0200 (Wed, 10 Aug 2011) $
 32  
  * @author Rodney Waldhoff
 33  
  */
 34  
 public final class NoOp implements Procedure, UnaryProcedure<Object>, BinaryProcedure<Object, Object>, Serializable {
 35  
     // static attributes
 36  
     // ------------------------------------------------------------------------
 37  
     /**
 38  
      * Basic NoOp instance.
 39  
      */
 40  2
     public static final NoOp INSTANCE = new NoOp();
 41  
     /**
 42  
      * serialVersionUID declaration.
 43  
      */
 44  
     private static final long serialVersionUID = 3768926349922273291L;
 45  
 
 46  
     // constructor
 47  
     // ------------------------------------------------------------------------
 48  
     /**
 49  
      * Create a new NoOp.
 50  
      */
 51  204
     public NoOp() {
 52  204
     }
 53  
 
 54  
     // predicate interface
 55  
     // ------------------------------------------------------------------------
 56  
     /**
 57  
      * {@inheritDoc}
 58  
      */
 59  
     public void run() {
 60  4
     }
 61  
 
 62  
     /**
 63  
      * {@inheritDoc}
 64  
      */
 65  
     public void run(Object obj) {
 66  240
     }
 67  
 
 68  
     /**
 69  
      * {@inheritDoc}
 70  
      */
 71  
     public void run(Object left, Object right) {
 72  12
     }
 73  
 
 74  
     /**
 75  
      * {@inheritDoc}
 76  
      */
 77  
     public boolean equals(Object that) {
 78  962
         return (that instanceof NoOp);
 79  
     }
 80  
 
 81  
     /**
 82  
      * {@inheritDoc}
 83  
      */
 84  
     public int hashCode() {
 85  1350
         return "NoOp".hashCode();
 86  
     }
 87  
 
 88  
     /**
 89  
      * {@inheritDoc}
 90  
      */
 91  
     public String toString() {
 92  1122
         return "NoOp";
 93  
     }
 94  
 
 95  
     // static methods
 96  
     // ------------------------------------------------------------------------
 97  
     /**
 98  
      * Get a NoOp instance.
 99  
      * @return NoOp
 100  
      */
 101  
     public static NoOp instance() {
 102  188
         return INSTANCE;
 103  
     }
 104  
 
 105  
     /**
 106  
      * Get a typed NoOp {@link UnaryProcedure}.
 107  
      * @param <A> type
 108  
      * @return <code>UnaryProcedure&lt;A&gt;</code>
 109  
      */
 110  
     @SuppressWarnings("unchecked")
 111  
     public static <A> UnaryProcedure<A> unaryInstance() {
 112  0
         return (UnaryProcedure<A>) INSTANCE;
 113  
     }
 114  
 
 115  
     /**
 116  
      * Get a typed NoOp {@link BinaryProcedure}.
 117  
      * @param <L> left type
 118  
      * @param <R> right type
 119  
      * @return <code>BinaryProcedure&lt;L, R&gt;</code>
 120  
      */
 121  
     @SuppressWarnings("unchecked")
 122  
     public static <L, R> BinaryProcedure<L, R> binaryInstance() {
 123  0
         return (BinaryProcedure<L, R>) INSTANCE;
 124  
     }
 125  
 }