Coverage Report - org.apache.giraph.conf.PerGraphTypeEnum
 
Classes in this File Line Coverage Branch Coverage Complexity
PerGraphTypeEnum
0%
0/27
0%
0/5
1.818
PerGraphTypeEnum$1
0%
0/1
N/A
1.818
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.giraph.conf;
 19  
 
 20  
 import org.apache.giraph.graph.GraphType;
 21  
 import org.apache.hadoop.conf.Configuration;
 22  
 
 23  
 /**
 24  
  * An enum stored per user graph type
 25  
  *
 26  
  * @param <T> Enum type
 27  
  */
 28  0
 public class PerGraphTypeEnum<T extends Enum<T>> {
 29  
   /** data for vertex id */
 30  
   private T vertexId;
 31  
   /** data for vertex value */
 32  
   private T vertexValue;
 33  
   /** data for edge value */
 34  
   private T edgeValue;
 35  
   /** data for outgoing message */
 36  
   private T outgoingMessage;
 37  
 
 38  
   /**
 39  
    * Create from options and configuration
 40  
    *
 41  
    * @param <T> enum type
 42  
    * @param options pre user graph type options
 43  
    * @param conf configuration
 44  
    * @return new object
 45  
    */
 46  
   public static <T extends Enum<T>> PerGraphTypeEnum<T> readFromConf(
 47  
       PerGraphTypeEnumConfOption<T> options, Configuration conf) {
 48  0
     PerGraphTypeEnum<T> pgte = new PerGraphTypeEnum<T>();
 49  0
     pgte.setFrom(options, conf);
 50  0
     return pgte;
 51  
   }
 52  
 
 53  
   /**
 54  
    * Set data from per user graph type set of options
 55  
    *
 56  
    * @param options per user graph type options
 57  
    * @param conf Configuration
 58  
    */
 59  
   public void setFrom(PerGraphTypeEnumConfOption<T> options,
 60  
       Configuration conf) {
 61  0
     setVertexId(options.getVertexId(), conf);
 62  0
     setVertexValue(options.getVertexValue(), conf);
 63  0
     setEdgeValue(options.getEdgeValue(), conf);
 64  0
     setOutgoingMessage(options.getOutgoingMessage(), conf);
 65  0
   }
 66  
 
 67  
   /**
 68  
    * Set the vertex id data from the option
 69  
    *
 70  
    * @param option EnumConfOption option to use
 71  
    * @param conf Configuration
 72  
    */
 73  
   public void setVertexId(EnumConfOption<T> option, Configuration conf) {
 74  0
     vertexId = option.get(conf);
 75  0
   }
 76  
 
 77  
   /**
 78  
    * Set the vertex value data from the option
 79  
    *
 80  
    * @param option EnumConfOption option to use
 81  
    * @param conf Configuration
 82  
    */
 83  
   public void setVertexValue(EnumConfOption<T> option, Configuration conf) {
 84  0
     vertexValue = option.get(conf);
 85  0
   }
 86  
 
 87  
   /**
 88  
    * Set the edge value data from the option
 89  
    *
 90  
    * @param option EnumConfOption option to use
 91  
    * @param conf Configuration
 92  
    */
 93  
   public void setEdgeValue(EnumConfOption<T> option, Configuration conf) {
 94  0
     edgeValue = option.get(conf);
 95  0
   }
 96  
 
 97  
   /**
 98  
    * Set the outgoing message value data from the option
 99  
    *
 100  
    * @param option EnumConfOption option to use
 101  
    * @param conf Configuration
 102  
    */
 103  
   public void setOutgoingMessage(EnumConfOption<T> option, Configuration conf) {
 104  0
     outgoingMessage = option.get(conf);
 105  0
   }
 106  
 
 107  
   /**
 108  
    * Get data for given GraphType
 109  
    *
 110  
    * @param graphType GraphType
 111  
    * @return data for given graph type
 112  
    */
 113  
   public T get(GraphType graphType) {
 114  0
     switch (graphType) {
 115  
     case VERTEX_ID:
 116  0
       return vertexId;
 117  
     case VERTEX_VALUE:
 118  0
       return vertexValue;
 119  
     case EDGE_VALUE:
 120  0
       return edgeValue;
 121  
     case OUTGOING_MESSAGE_VALUE:
 122  0
       return outgoingMessage;
 123  
     default:
 124  0
       throw new IllegalArgumentException(
 125  
           "Don't know how to handle GraphType " + graphType);
 126  
     }
 127  
   }
 128  
 
 129  
   public T getEdgeValue() {
 130  0
     return edgeValue;
 131  
   }
 132  
 
 133  
   public T getOutgoingMessage() {
 134  0
     return outgoingMessage;
 135  
   }
 136  
 
 137  
   public T getVertexId() {
 138  0
     return vertexId;
 139  
   }
 140  
 
 141  
   public T getVertexValue() {
 142  0
     return vertexValue;
 143  
   }
 144  
 }