Coverage Report - org.dishevelled.iconbundle.IconState
 
Classes in this File Line Coverage Branch Coverage Complexity
IconState
95%
19/20
85%
12/14
1
 
 1  
 /*
 2  
 
 3  
     dsh-iconbundle  Bundles of variants for icon images.
 4  
     Copyright (c) 2003-2011 held jointly by the individual authors.
 5  
 
 6  
     This library is free software; you can redistribute it and/or modify it
 7  
     under the terms of the GNU Lesser General Public License as published
 8  
     by the Free Software Foundation; either version 3 of the License, or (at
 9  
     your option) any later version.
 10  
 
 11  
     This library is distributed in the hope that it will be useful, but WITHOUT
 12  
     ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
 13  
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 14  
     License for more details.
 15  
 
 16  
     You should have received a copy of the GNU Lesser General Public License
 17  
     along with this library;  if not, write to the Free Software Foundation,
 18  
     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
 19  
 
 20  
     > http://www.fsf.org/licensing/licenses/lgpl.html
 21  
     > http://www.opensource.org/licenses/lgpl-license.php
 22  
 
 23  
 */
 24  
 package org.dishevelled.iconbundle;
 25  
 
 26  
 import java.util.List;
 27  
 import java.util.Arrays;
 28  
 import java.util.Collections;
 29  
 
 30  
 import java.io.Serializable;
 31  
 
 32  
 /**
 33  
  * Typesafe enumeration of icon states.
 34  
  *
 35  
  * @author  Michael Heuer
 36  
  * @version $Revision: 974 $ $Date: 2011-01-04 21:40:23 -0600 (Tue, 04 Jan 2011) $
 37  
  */
 38  
 public final class IconState
 39  
     implements Serializable
 40  
 {
 41  
     /** State name. */
 42  
     private String name;
 43  
 
 44  
 
 45  
     /**
 46  
      * Create a new IconState with the specified name.
 47  
      *
 48  
      * @param name state name
 49  
      */
 50  
     private IconState(final String name)
 51  7
     {
 52  7
         this.name = name;
 53  7
     }
 54  
 
 55  
 
 56  
     /**
 57  
      * Return the state name.
 58  
      *
 59  
      * @return the state name
 60  
      */
 61  
     public String toString()
 62  
     {
 63  48
         return name;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Return true if this icon state is <code>IconState.NORMAL</code>.
 68  
      *
 69  
      * @return true if this icon state is <code>IconState.NORMAL</code>
 70  
      */
 71  
     public boolean isNormal()
 72  
     {
 73  6
         return (this == NORMAL);
 74  
     }
 75  
 
 76  
     /**
 77  
      * Return true if this icon state is <code>IconState.ACTIVE</code>.
 78  
      *
 79  
      * @return true if this icon state is <code>IconState.ACTIVE</code>
 80  
      */
 81  
     public boolean isActive()
 82  
     {
 83  6
         return (this == ACTIVE);
 84  
     }
 85  
 
 86  
     /**
 87  
      * Return true if this icon state is <code>IconState.MOUSEOVER</code>.
 88  
      *
 89  
      * @return true if this icon state is <code>IconState.MOUSEOVER</code>
 90  
      */
 91  
     public boolean isMouseover()
 92  
     {
 93  6
         return (this == MOUSEOVER);
 94  
     }
 95  
 
 96  
     /**
 97  
      * Return true if this icon state is <code>IconState.SELECTED</code>.
 98  
      *
 99  
      * @return true if this icon state is <code>IconState.SELECTED</code>
 100  
      */
 101  
     public boolean isSelected()
 102  
     {
 103  6
         return (this == SELECTED);
 104  
     }
 105  
 
 106  
     /**
 107  
      * Return true if this icon state is <code>IconState.SELECTED_MOUSEOVER</code>.
 108  
      *
 109  
      * @return true if this icon state is <code>IconState.SELECTED_MOUSEOVER</code>
 110  
      */
 111  
     public boolean isSelectedMouseover()
 112  
     {
 113  0
         return (this == SELECTED_MOUSEOVER);
 114  
     }
 115  
 
 116  
     /**
 117  
      * Return true if this icon state is <code>IconState.DRAGGING</code>.
 118  
      *
 119  
      * @return true if this icon state is <code>IconState.DRAGGING</code>
 120  
      */
 121  
     public boolean isDragging()
 122  
     {
 123  6
         return (this == DRAGGING);
 124  
     }
 125  
 
 126  
     /**
 127  
      * Return true if this icon state is <code>IconState.DISABLED</code>.
 128  
      *
 129  
      * @return true if this icon state is <code>IconState.DISABLED</code>
 130  
      */
 131  
     public boolean isDisabled()
 132  
     {
 133  6
         return (this == DISABLED);
 134  
     }
 135  
 
 136  
 
 137  
     /** Normal icon state. */
 138  1
     public static final IconState NORMAL = new IconState("normal");
 139  
 
 140  
     /** Active icon state. */
 141  1
     public static final IconState ACTIVE = new IconState("active");
 142  
 
 143  
     /** Mouseover icon state. */
 144  1
     public static final IconState MOUSEOVER = new IconState("mouseover");
 145  
 
 146  
     /** Selected icon state. */
 147  1
     public static final IconState SELECTED = new IconState("selected");
 148  
 
 149  
     /** Selected mouseover icon state. */
 150  1
     public static final IconState SELECTED_MOUSEOVER = new IconState("selected-mouseover");
 151  
 
 152  
     /** Dragging icon state. */
 153  1
     public static final IconState DRAGGING = new IconState("dragging");
 154  
 
 155  
     /** Disabled icon state. */
 156  1
     public static final IconState DISABLED = new IconState("disabled");
 157  
 
 158  
     /**
 159  
      * Private array of enumeration values.
 160  
      */
 161  1
     private static final IconState[] VALUES_ARRAY = {
 162  
                                                       NORMAL,
 163  
                                                       ACTIVE,
 164  
                                                       MOUSEOVER,
 165  
                                                       SELECTED,
 166  
                                                       SELECTED_MOUSEOVER,
 167  
                                                       DRAGGING,
 168  
                                                       DISABLED
 169  
                                                     };
 170  
 
 171  
     /**
 172  
      * Public list of enumeration values.
 173  
      */
 174  1
     public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
 175  
 }