View Javadoc

1   /***
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * For more information visit
11   *         http://72miles.com and
12   *         http://architecturerules.googlecode.com/svn/docs/index.html
13   */
14  
15  package com.seventytwomiles.architecturerules.exceptions;
16  
17  /***
18   * <p>Exception to be thrown when any <code>Rule</code> fails, that is to say,
19   * the rule is violoated.</p>
20   *
21   * @author mikenereson
22   * @see ArchitectureException
23   */
24  public class DependencyConstraintException extends ArchitectureException {
25  
26  
27      /***
28       * @see RuntimeException#RuntimeException()
29       */
30      public DependencyConstraintException() {
31          super("dependency constraint");
32      }
33  
34  
35      /***
36       * @see RuntimeException#RuntimeException(String)
37       */
38      public DependencyConstraintException(final String message) {
39          super(message);
40      }
41  
42  
43      /***
44       * @see RuntimeException#RuntimeException(Throwable)
45       */
46      public DependencyConstraintException(final Throwable cause) {
47          super("dependency constraint", cause);
48      }
49  
50  
51      /***
52       * @see RuntimeException#RuntimeException(String,Throwable)
53       */
54      public DependencyConstraintException(final String message,
55                                           final Throwable cause) {
56          super(message, cause);
57      }
58  
59  
60      /***
61       * <p>Reports which <code>Rule</code> was broken, by its <tt>id</tt>, and
62       * what packages that <code>Rule</code> governs.</p>
63       *
64       * @param ruleId   String id of the <code>Rule</code> that was violated.
65       * @param packages String listing each package constrained by the violated
66       *                 <code>Rule</code>
67       * @param cause    Throwable any exception that was thrown
68       */
69      public DependencyConstraintException(final String ruleId,
70                                           final String packages,
71                                           final Throwable cause) {
72  
73          this("dependency constraint failed in '{id}' rule which constrains packages '{efferent}'"
74                  .replaceAll("//{id}", ruleId)
75                  .replaceAll("//{efferent}", packages.trim())
76                  .replaceAll("//[", "")
77                  .replaceAll("//]", ""), cause);
78      }
79  }