View Javadoc

1   /*
2    * Copyright 2007-2011 smartics, Kronseder & Reiner GmbH
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   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.exceptions.report.sort;
17  
18  import java.util.Comparator;
19  
20  import de.smartics.exceptions.code.DefaultCodeComparator;
21  import de.smartics.exceptions.core.Code;
22  import de.smartics.exceptions.report.sort.CodeUtils.CodeContainer;
23  
24  /**
25   * Compares exception code instances. The instances are ordered by their codes
26   * natural ordering.
27   *
28   * @see DefaultCodeComparator
29   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
30   * @version $Revision:591 $
31   */
32  public class CodeComparator implements Comparator<CodeContainer>
33  {
34    // ********************************* Fields *********************************
35  
36    // --- constants ------------------------------------------------------------
37  
38    // --- members --------------------------------------------------------------
39  
40    /**
41     * The comparator of the codes.
42     */
43    private final DefaultCodeComparator<Code> comparator =
44        new DefaultCodeComparator<Code>();
45  
46    // ****************************** Initializer *******************************
47  
48    // ****************************** Constructors ******************************
49  
50    /**
51     * Default constructor.
52     */
53    public CodeComparator()
54    {
55    }
56  
57    // ****************************** Inner Classes *****************************
58  
59    // ********************************* Methods ********************************
60  
61    // --- init -----------------------------------------------------------------
62  
63    // --- get&set --------------------------------------------------------------
64  
65    // --- business -------------------------------------------------------------
66  
67    /**
68     * {@inheritDoc}
69     * <p>
70     * Uses {@link DefaultCodeComparator} to compare codes.
71     *
72     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
73     */
74    public int compare(final CodeContainer o1, final CodeContainer o2)
75    {
76      return comparator.compare(o1.getCode(), o2.getCode());
77    }
78  
79    // --- object basics --------------------------------------------------------
80  
81  }