Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
17   149   14   1.42
4   63   0.82   4
12     1.17  
3    
 
 
  Language       Line # 31 15 12 0% 0.0
  Language.LanguageKeyComparator       Line # 128 1 1 0% 0.0
  Language.LanguageValueComparator       Line # 138 1 1 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.model;
20   
21    import java.util.Comparator;
22   
23    import org.apache.commons.lang.builder.CompareToBuilder;
24    import org.apache.commons.lang.builder.ToStringBuilder;
25   
26    /**
27    * Models a language entry.
28    *
29    * @author ready
30    */
 
31    public class Language extends AbstractEntity {
32   
33   
34    /**
35    *
36    */
37    private static final long serialVersionUID = 1L;
38   
39    private String locale;
40   
41    private String resourceKey;
42   
43    private String resourceValue;
44   
45    /**
46    * Default constructor (required by Hibernate).
47    *
48    * <p>
49    * PENDING: should be <code>private</code> so that it can only be used by
50    * Hibernate, to ensure that the fields which form an instance's identity
51    * are always initialized/never <tt>null</tt>.
52    * </p>
53    */
 
54  0 toggle public Language() {
55    }
56   
 
57  0 toggle public Language(String locale, String key) {
58  0 setLocale(locale);
59  0 setResourceKey(key);
60    }
61   
62    /**
63    * Convenience constructor to set the value too.
64    */
 
65  0 toggle public Language(String locale, String key, String value) {
66  0 this(locale, key);
67  0 setResourceValue(value);
68    }
69   
 
70  0 toggle public String getLocale() {
71  0 return locale;
72    }
73   
 
74  0 toggle public void setLocale(String locale) {
75  0 if (locale == null) {
76  0 throw new IllegalArgumentException("null locale");
77    }
78  0 this.locale = locale;
79    }
80   
 
81  0 toggle public String getResourceKey() {
82  0 return resourceKey;
83    }
84   
 
85  0 toggle public void setResourceKey(String resourceKey) {
86  0 if (resourceKey == null) {
87  0 throw new IllegalArgumentException("null resourceKey");
88    }
89  0 this.resourceKey = resourceKey;
90    }
91   
 
92  0 toggle public String getResourceValue() {
93  0 return resourceValue;
94    }
95   
 
96  0 toggle public void setResourceValue(String resourceValue) {
97  0 this.resourceValue = resourceValue;
98    }
99   
100    // @Override
101    // public boolean equals(Object obj) {
102    // if (this == obj) {
103    // return true;
104    // }
105    //
106    // if (obj instanceof Language) {
107    // final Language other = (Language)obj;
108    //
109    // return this.resourceKey.equals(other.resourceKey)
110    // && this.locale.equals(other.locale);
111    // }
112    // return false;
113    // }
114    //
115    // @Override
116    // public int hashCode() {
117    // return this.resourceKey.hashCode() + this.locale.hashCode();
118    // }
119    //
 
120  0 toggle @Override
121    public String toString() {
122  0 return new ToStringBuilder(this).append("id", getId()).append("resourceKey",
123    getResourceKey()).append("locale", getLocale()).append("value", getResourceValue()).toString();
124    }
125   
126    public static final Comparator<Language> KEY_COMPARATOR = new LanguageKeyComparator();
127   
 
128    private static class LanguageKeyComparator implements Comparator<Language> {
129   
 
130  0 toggle public int compare(Language o1, Language o2) {
131  0 return new CompareToBuilder().append(o1.getResourceKey(), o2.getResourceKey()).append(o1.getLocale(), o2.getLocale()).append(o1.getId(), o2.getId()).toComparison();
132    }
133   
134    }
135   
136    public static final Comparator<Language> VALUE_COMPARATOR = new LanguageValueComparator();
137   
 
138    private static class LanguageValueComparator implements Comparator<Language> {
139   
 
140  0 toggle public int compare(Language o1, Language o2) {
141  0 return new CompareToBuilder()
142    .append(o1.getResourceValue(), o2.getResourceValue())
143    .append(o1.getResourceKey(), o2.getResourceKey())
144    .append(o1.getId(), o2.getId()).toComparison();
145    }
146   
147    }
148   
149    }