View Javadoc
1   /**
2    * Copyright (C) 2014-2016 Philip Helger (www.helger.com)
3    * philip[at]helger[dot]com
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    *         http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package com.helger.schematron.pure.bound.xpath;
18  
19  import javax.annotation.Nonnull;
20  import javax.annotation.concurrent.Immutable;
21  import javax.xml.xpath.XPathExpression;
22  
23  import com.helger.commons.ValueEnforcer;
24  import com.helger.commons.annotation.ReturnsMutableCopy;
25  import com.helger.commons.collection.ext.ICommonsList;
26  import com.helger.commons.string.ToStringGenerator;
27  import com.helger.schematron.pure.model.PSRule;
28  
29  /**
30   * This class represents a single XPath-bound rule-element.
31   *
32   * @author Philip Helger
33   */
34  @Immutable
35  public class PSXPathBoundRule
36  {
37    private final PSRule m_aRule;
38    private final String m_sRuleExpression;
39    private final XPathExpression m_aBoundRuleExpression;
40  
41    private final ICommonsList <PSXPathBoundAssertReport> m_aBoundAssertReports;
42  
43    public PSXPathBoundRule (@Nonnull final PSRule aRule,
44                             @Nonnull final String sRuleExpression,
45                             @Nonnull final XPathExpression aBoundRuleExpression,
46                             @Nonnull final ICommonsList <PSXPathBoundAssertReport> aBoundAssertReports)
47    {
48      ValueEnforcer.notNull (aRule, "Rule");
49      ValueEnforcer.notEmpty (sRuleExpression, "RuleExpression");
50      ValueEnforcer.notNull (aBoundRuleExpression, "BoundRuleExpression");
51      ValueEnforcer.notNull (aBoundAssertReports, "BoundAssertReports");
52      m_aRule = aRule;
53      m_sRuleExpression = sRuleExpression;
54      m_aBoundRuleExpression = aBoundRuleExpression;
55      m_aBoundAssertReports = aBoundAssertReports;
56    }
57  
58    @Nonnull
59    public PSRule getRule ()
60    {
61      return m_aRule;
62    }
63  
64    @Nonnull
65    public String getRuleExpression ()
66    {
67      return m_sRuleExpression;
68    }
69  
70    @Nonnull
71    public XPathExpression getBoundRuleExpression ()
72    {
73      return m_aBoundRuleExpression;
74    }
75  
76    @Nonnull
77    @ReturnsMutableCopy
78    public ICommonsList <PSXPathBoundAssertReport> getAllBoundAssertReports ()
79    {
80      return m_aBoundAssertReports.getClone ();
81    }
82  
83    @Override
84    public String toString ()
85    {
86      return new ToStringGenerator (this).append ("rule", m_aRule)
87                                         .append ("ruleExpression", m_sRuleExpression)
88                                         .append ("boundRuleExpression", m_aBoundRuleExpression)
89                                         .append ("boundAssertReports", m_aBoundAssertReports)
90                                         .toString ();
91    }
92  }