1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.lesscss.internal.resources

File LESSObjectPropertyResourceReference.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
10
5
1
86
45
6
0.6
2
5
1.2

Classes

Class Line # Actions
LESSObjectPropertyResourceReference 34 10 0% 6 7
0.588235358.8%
 

Contributing tests

This file is covered by 3 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.lesscss.internal.resources;
21   
22    import org.xwiki.bridge.DocumentAccessBridge;
23    import org.xwiki.lesscss.compiler.LESSCompilerException;
24    import org.xwiki.lesscss.resources.LESSResourceReference;
25    import org.xwiki.model.reference.EntityReferenceSerializer;
26    import org.xwiki.model.reference.ObjectPropertyReference;
27   
28    /**
29    * A reference to a LESS resource containing in an XObject property in the wiki.
30    *
31    * @since 6.4M2
32    * @version $Id: 02eaa97b63f8089867d91abef91141626cd31970 $
33    */
 
34    public class LESSObjectPropertyResourceReference implements LESSResourceReference
35    {
36    private ObjectPropertyReference objectPropertyReference;
37   
38    private EntityReferenceSerializer<String> entityReferenceSerializer;
39   
40    private DocumentAccessBridge bridge;
41   
42    /**
43    * Constructor.
44    * @param objectPropertyReference reference to the property of an XObject storing some LESS code
45    * @param entityReferenceSerializer object reference serializer
46    * @param bridge bridge to access to documents
47    */
 
48  5 toggle public LESSObjectPropertyResourceReference(ObjectPropertyReference objectPropertyReference,
49    EntityReferenceSerializer<String> entityReferenceSerializer,
50    DocumentAccessBridge bridge)
51    {
52  5 this.objectPropertyReference = objectPropertyReference;
53  5 this.entityReferenceSerializer = entityReferenceSerializer;
54  5 this.bridge = bridge;
55    }
56   
 
57  0 toggle @Override
58    public boolean equals(Object o)
59    {
60  0 if (o instanceof LESSObjectPropertyResourceReference) {
61  0 LESSObjectPropertyResourceReference lessObjectPropertyResourceReference =
62    (LESSObjectPropertyResourceReference) o;
63  0 return objectPropertyReference.equals(lessObjectPropertyResourceReference.objectPropertyReference);
64    }
65   
66  0 return false;
67    }
68   
 
69  4 toggle @Override
70    public int hashCode()
71    {
72  4 return objectPropertyReference.hashCode();
73    }
74   
 
75  2 toggle @Override
76    public String getContent(String skin) throws LESSCompilerException
77    {
78  2 return (String) bridge.getProperty(objectPropertyReference);
79    }
80   
 
81  4 toggle @Override
82    public String serialize()
83    {
84  4 return String.format("LessXObjectProperty[%s]", entityReferenceSerializer.serialize(objectPropertyReference));
85    }
86    }