1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.resource.entity

File EntityResourceAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
13
6
1
101
49
9
0.69
2.17
6
1.5

Classes

Class Line # Actions
EntityResourceAction 31 13 0% 9 4
0.8484%
 

Contributing tests

This file is covered by 13 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.resource.entity;
21   
22    import org.apache.commons.lang3.builder.EqualsBuilder;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24   
25    /**
26    * Represents the action to be executed on an Entity Resource (eg "view", "delete", "get", etc).
27    *
28    * @version $Id: 656d0d614c488276966e592939311e32ec008c3f $
29    * @since 6.1M2
30    */
 
31    public class EntityResourceAction
32    {
33    /**
34    * The View Action.
35    */
36    public static final EntityResourceAction VIEW = new EntityResourceAction("view");
37   
38    /**
39    * The action name (e.g. "view", "download", etc).
40    */
41    private String actionName;
42   
43    /**
44    * @param actionName see {@link #getActionName()}
45    */
 
46  21121 toggle public EntityResourceAction(String actionName)
47    {
48  21146 this.actionName = actionName;
49    }
50   
51    /**
52    * Converts a string to an {@link EntityResourceAction} instance.
53    *
54    * @param actionName see {@link #getActionName()}
55    * @return the object representing the action passed as a string
56    */
 
57  21129 toggle public static EntityResourceAction fromString(String actionName)
58    {
59  21129 return new EntityResourceAction(actionName);
60    }
61   
62    /**
63    * @return the action name (eg "view")
64    */
 
65  48364 toggle public String getActionName()
66    {
67  48388 return this.actionName;
68    }
69   
 
70  9481 toggle @Override
71    public String toString()
72    {
73  9492 return getActionName();
74    }
75   
 
76  19012 toggle @Override
77    public int hashCode()
78    {
79  19018 return new HashCodeBuilder(13, 7)
80    .append(getActionName())
81    .toHashCode();
82    }
83   
 
84  7 toggle @Override
85    public boolean equals(Object object)
86    {
87  7 if (object == null) {
88  0 return false;
89    }
90  7 if (object == this) {
91  1 return true;
92    }
93  6 if (object.getClass() != getClass()) {
94  0 return false;
95    }
96  6 EntityResourceAction rhs = (EntityResourceAction) object;
97  6 return new EqualsBuilder()
98    .append(getActionName(), rhs.getActionName())
99    .isEquals();
100    }
101    }