View Javadoc
1   /**
2    * Copyright (C) 2014-2015 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 java.util.List;
20  
21  import javax.annotation.Nonnull;
22  import javax.annotation.concurrent.Immutable;
23  import javax.xml.xpath.XPathExpression;
24  
25  import com.helger.commons.ValueEnforcer;
26  import com.helger.commons.annotation.ReturnsMutableCopy;
27  import com.helger.commons.collection.CollectionHelper;
28  import com.helger.commons.string.ToStringGenerator;
29  import com.helger.schematron.pure.model.PSRule;
30  
31  /**
32   * This class represents a single XPath-bound rule-element.
33   *
34   * @author Philip Helger
35   */
36  @Immutable
37  public class PSXPathBoundRule
38  {
39    private final PSRule m_aRule;
40    private final String m_sRuleExpression;
41    private final XPathExpression m_aBoundRuleExpression;
42    private final List <PSXPathBoundAssertReport> m_aBoundAssertReports;
43  
44    public PSXPathBoundRule (@Nonnull final PSRule aRule,
45                             @Nonnull final String sRuleExpression,
46                             @Nonnull final XPathExpression aBoundRuleExpression,
47                             @Nonnull final List <PSXPathBoundAssertReport> aBoundAssertReports)
48    {
49      ValueEnforcer.notNull (aRule, "Rule");
50      ValueEnforcer.notEmpty (sRuleExpression, "RuleExpression");
51      ValueEnforcer.notNull (aBoundRuleExpression, "BoundRuleExpression");
52      ValueEnforcer.notNull (aBoundAssertReports, "BoundAssertReports");
53      m_aRule = aRule;
54      m_sRuleExpression = sRuleExpression;
55      m_aBoundRuleExpression = aBoundRuleExpression;
56      m_aBoundAssertReports = aBoundAssertReports;
57    }
58  
59    @Nonnull
60    public PSRule getRule ()
61    {
62      return m_aRule;
63    }
64  
65    @Nonnull
66    public String getRuleExpression ()
67    {
68      return m_sRuleExpression;
69    }
70  
71    @Nonnull
72    public XPathExpression getBoundRuleExpression ()
73    {
74      return m_aBoundRuleExpression;
75    }
76  
77    @Nonnull
78    @ReturnsMutableCopy
79    public List <PSXPathBoundAssertReport> getAllBoundAssertReports ()
80    {
81      return CollectionHelper.newList (m_aBoundAssertReports);
82    }
83  
84    @Override
85    public String toString ()
86    {
87      return new ToStringGenerator (this).append ("rule", m_aRule)
88                                         .append ("ruleExpression", m_sRuleExpression)
89                                         .append ("boundRuleExpression", m_aBoundRuleExpression)
90                                         .append ("boundAssertReports", m_aBoundAssertReports)
91                                         .toString ();
92    }
93  }