1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.resource.entity

File EntityResourceAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% 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 47 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  83751 toggle public EntityResourceAction(String actionName)
47    {
48  83776 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  83696 toggle public static EntityResourceAction fromString(String actionName)
58    {
59  83723 return new EntityResourceAction(actionName);
60    }
61   
62    /**
63    * @return the action name (eg "view")
64    */
 
65  296146 toggle public String getActionName()
66    {
67  296203 return this.actionName;
68    }
69   
 
70  36708 toggle @Override
71    public String toString()
72    {
73  36714 return getActionName();
74    }
75   
 
76  73403 toggle @Override
77    public int hashCode()
78    {
79  73435 return new HashCodeBuilder(13, 7)
80    .append(getActionName())
81    .toHashCode();
82    }
83   
 
84  28072 toggle @Override
85    public boolean equals(Object object)
86    {
87  28078 if (object == null) {
88  0 return false;
89    }
90  28072 if (object == this) {
91  1 return true;
92    }
93  28075 if (object.getClass() != getClass()) {
94  0 return false;
95    }
96  28070 EntityResourceAction rhs = (EntityResourceAction) object;
97  28075 return new EqualsBuilder()
98    .append(getActionName(), rhs.getActionName())
99    .isEquals();
100    }
101    }