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

File ResourceType.java

 

Coverage histogram

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

Code metrics

6
15
7
1
114
57
10
0.67
2.14
7
1.43

Classes

Class Line # Actions
ResourceType 32 15 0% 10 4
0.8571428785.7%
 

Contributing tests

This file is covered by 25 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;
21   
22    import org.apache.commons.lang3.builder.EqualsBuilder;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24    import org.xwiki.stability.Unstable;
25   
26    /**
27    * Represents the type of Resource (eg Entity, Temporary, etc).
28    *
29    * @version $Id: 719a80e71616679baf87940f76c44d4708a1d455 $
30    * @since 6.1M2
31    */
 
32    public class ResourceType
33    {
34    /**
35    * The resource type id (e.g. "bin", "tmp", etc).
36    */
37    private String id;
38   
39    private boolean isStatic;
40   
41    /**
42    * @param id see {@link #getId()}
43    */
 
44  14712 toggle public ResourceType(String id)
45    {
46  14719 this(id, false);
47    }
48   
49    /**
50    * @param id see {@link #getId()}
51    * @param isStatic see {@link #isStatic()}
52    *
53    * @since 11.0
54    */
 
55  14685 toggle @Unstable
56    public ResourceType(String id, boolean isStatic)
57    {
58  14690 this.id = id;
59  14706 this.isStatic = isStatic;
60    }
61   
62    /**
63    * @return the technical id of the Resource Type
64    */
 
65  764321 toggle public String getId()
66    {
67  764670 return this.id;
68    }
69   
 
70  36702 toggle @Override
71    public String toString()
72    {
73  36716 return getId();
74    }
75   
 
76  73385 toggle @Override
77    public int hashCode()
78    {
79  73422 return new HashCodeBuilder(13, 7)
80    .append(getId())
81    .toHashCode();
82    }
83   
 
84  210471 toggle @Override
85    public boolean equals(Object object)
86    {
87  210532 if (object == null) {
88  0 return false;
89    }
90  210530 if (object == this) {
91  5411 return true;
92    }
93  205096 if (object.getClass() != getClass()) {
94  0 return false;
95    }
96  205154 ResourceType rhs = (ResourceType) object;
97  205142 return new EqualsBuilder()
98    .append(getId(), rhs.getId())
99    .isEquals();
100    }
101   
102    /**
103    * @return true if this type represents a static resource containing only static content and which should be served
104    * directly by the Servlet Container without going through XWiki processing and handling
105    * (e.g: a ResourcesResource or a SkinResource)
106    *
107    * @since 11.0
108    */
 
109  48924 toggle @Unstable
110    public boolean isStatic()
111    {
112  48930 return this.isStatic;
113    }
114    }