Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EntityUtils |
|
| 2.0;2 |
1 | package org.jtheque.core.utils.db; | |
2 | ||
3 | import org.jtheque.core.managers.persistence.able.Entity; | |
4 | ||
5 | /* | |
6 | * This file is part of JTheque. | |
7 | * | |
8 | * JTheque is free software: you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation, either version 3 of the License. | |
11 | * | |
12 | * JTheque is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * An utility class for the entity. | |
23 | * | |
24 | * @author Baptiste Wicht | |
25 | */ | |
26 | public final class EntityUtils { | |
27 | /** | |
28 | * This is an utility class, not instanciable. | |
29 | */ | |
30 | private EntityUtils() { | |
31 | 0 | super(); |
32 | 0 | } |
33 | ||
34 | /** | |
35 | * Search in a collection to found a specific id. | |
36 | * | |
37 | * @param list The list to search in. | |
38 | * @param id The id to find. | |
39 | * @return true if the id is in the list else false. | |
40 | */ | |
41 | public static boolean containsID(Iterable<? extends Entity> list, int id) { | |
42 | 22 | boolean found = false; |
43 | ||
44 | 22 | for (Entity d : list) { |
45 | 120 | if (d.getId() == id) { |
46 | 16 | found = true; |
47 | 16 | break; |
48 | } | |
49 | } | |
50 | ||
51 | 22 | return found; |
52 | } | |
53 | } |