Coverage Report - com.buckosoft.fibs.domain.config.RatingGraphConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
RatingGraphConfig
100%
26/26
83%
5/6
1.333
RatingGraphConfig$Type
100%
4/4
N/A
1.333
 
 1  
 /******************************************************************************
 2  
  * RatingGraphConfig.java - Configure the ratings graph
 3  
  * $Id$
 4  
  * 
 5  
  * BuckoFIBS - Backgammon by BuckoSoft
 6  
  * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
 7  
  * 
 8  
  * $Log$
 9  
  * Revision 1.3  2010/03/03 13:12:22  inim
 10  
  * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
 11  
  *
 12  
  * Revision 1.2  2010/03/03 12:19:49  inim
 13  
  * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
 14  
  *
 15  
  * Revision 1.1  2010/02/04 05:57:53  inim
 16  
  * Mavenized project folder layout
 17  
  *
 18  
  * Revision 1.2  2010/01/29 23:10:09  dick
 19  
  * Need to be able to clone().
 20  
  *
 21  
  * Revision 1.1  2010/01/26 19:11:21  dick
 22  
  * Configure the ratings graph.
 23  
  *
 24  
  */
 25  
 
 26  
 /* 
 27  
  * This program is free software: you can redistribute it and/or modify
 28  
  * it under the terms of the GNU General Public License as published by
 29  
  * the Free Software Foundation, either version 3 of the License, or
 30  
  * (at your option) any later version.
 31  
  *
 32  
  * This program is distributed in the hope that it will be useful,
 33  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 34  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 35  
  * GNU General Public License for more details.
 36  
  *
 37  
  * You should have received a copy of the GNU General Public License
 38  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 39  
  *
 40  
  * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
 41  
  * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
 42  
  * 
 43  
  */
 44  
 package com.buckosoft.fibs.domain.config;
 45  
 
 46  
 import java.util.Date;
 47  
 
 48  
 /** Configure the ratings graph.
 49  
  * @author Dick Balaska
 50  
  * @since Jan 26, 2010
 51  
  * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/config/RatingGraphConfig.java">cvs RatingGraphConfig.java</a>
 52  
  */
 53  10
 public class RatingGraphConfig implements Cloneable {
 54  
         
 55  
         /** Define what type of data to display in the Rating Graph.
 56  
          * @author Dick Balaska
 57  
          * @since Jan 26, 2010
 58  
          * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/config/RatingGraphConfig.java">cvs RatingGraphConfig.java</a>
 59  
          */
 60  4
         public enum Type {
 61  
                 /** Display all of the matches we have played. */
 62  1
                 displayAllMatches,
 63  
                 /** Display the last (constant) number of matches that we've played. */
 64  1
                 displayLastXMatches,
 65  
                 /** Display all matches from a (constant) date. */
 66  1
                 displayFromDate
 67  
         }
 68  
         
 69  10
         private        Type        type = Type.displayLastXMatches;
 70  10
         private        int                matchCount = 100;
 71  10
         private        Date        firstMatchDate = new Date(0);
 72  
         
 73  
         /** make a copy of this RatingGraphConfig
 74  
          * @return The new copy of this RatingGraphConfig
 75  
          */
 76  
         public RatingGraphConfig clone() {
 77  1
                 RatingGraphConfig rgc = new RatingGraphConfig();
 78  1
                 rgc.setTypeAsInt(this.getTypeAsInt());
 79  1
                 rgc.setMatchCount(this.getMatchCount());
 80  1
                 rgc.firstMatchDate = new Date(this.firstMatchDate.getTime());
 81  1
                 return(rgc);
 82  
         }
 83  
 
 84  
         /** Fetch the {@link com.buckosoft.fibs.domain.config.RatingGraphConfig.Type} of graph to display
 85  
          * @return the type
 86  
          */
 87  
         public Type getType() {
 88  4
                 return type;
 89  
         }
 90  
 
 91  
         /** Set the type of graph that the user wants to display.
 92  
          * @param type the type to set
 93  
          */
 94  
         public void setType(Type type) {
 95  2
                 this.type = type;
 96  2
         }
 97  
 
 98  
         /** Set the type of graph as an int.  Useful for database access.
 99  
          * @param type The (most likely) stored type
 100  
          */
 101  
         public void setTypeAsInt(int type) {
 102  7
                 if (type == Type.displayAllMatches.ordinal())
 103  2
                         this.type = Type.displayAllMatches;
 104  5
                 else if (type == Type.displayLastXMatches.ordinal())
 105  3
                         this.type = Type.displayLastXMatches;
 106  2
                 else if (type == Type.displayFromDate.ordinal())
 107  2
                         this.type = Type.displayFromDate;
 108  7
         }
 109  
         
 110  
         /** Fetch the type of graph as an int.  Useful for database access.
 111  
          * @return What type of graph the user wants displayed.
 112  
          */
 113  
         public int getTypeAsInt() {
 114  7
                 return(this.type.ordinal());
 115  
         }
 116  
 
 117  
         /** Get the number of matches that the user wants to display.
 118  
          * Useful only for Type.displayLastXMatches
 119  
          * @return the matchCount
 120  
          */
 121  
         public int getMatchCount() {
 122  7
                 return matchCount;
 123  
         }
 124  
 
 125  
         /** Set the number of matches that the user wants to display.
 126  
          * @param matchCount the matchCount to set
 127  
          */
 128  
         public void setMatchCount(int matchCount) {
 129  5
                 this.matchCount = matchCount;
 130  5
         }
 131  
 
 132  
         /** Get the date of the first match to display.
 133  
          * @return the firstMatchDate
 134  
          */
 135  
         public Date getFirstMatchDate() {
 136  4
                 return firstMatchDate;
 137  
         }
 138  
 
 139  
         /** Set the date of the first match to display.
 140  
          * @param firstMatchDate the firstMatchDate to set
 141  
          */
 142  
         public void setFirstMatchDate(Date firstMatchDate) {
 143  2
                 this.firstMatchDate = firstMatchDate;
 144  2
         }
 145  
         
 146  
         
 147  
 }