Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
MergeConfiguration | 30 | 2 | 0% | 3 | 6 | ||
MergeConfiguration.Version | 44 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.diff; | |
21 | ||
22 | import java.util.HashMap; | |
23 | ||
24 | /** | |
25 | * Setup merge behavior. | |
26 | * | |
27 | * @param <E> the type of compared elements | |
28 | * @version $Id: ab31e7fb13d1653b3494f5c9eb8247fb2f5a00e7 $ | |
29 | */ | |
30 | public class MergeConfiguration<E> extends HashMap<String, Object> | |
31 | { | |
32 | /** | |
33 | * The name of the key used to setup the default fallback to use when finding a conflict. | |
34 | */ | |
35 | public static final String KEY_FALLBACKONCONFLICT = "fallbackonconflict"; | |
36 | ||
37 | private static final long serialVersionUID = 1L; | |
38 | ||
39 | /** | |
40 | * One of the merged versions. | |
41 | * | |
42 | * @version $Id: ab31e7fb13d1653b3494f5c9eb8247fb2f5a00e7 $ | |
43 | */ | |
44 | public enum Version | |
45 | { | |
46 | /** | |
47 | * The common ancestor. | |
48 | */ | |
49 | PREVIOUS, | |
50 | ||
51 | /** | |
52 | * The new version. | |
53 | */ | |
54 | NEXT, | |
55 | ||
56 | /** | |
57 | * The current version. | |
58 | */ | |
59 | CURRENT | |
60 | } | |
61 | ||
62 | /** | |
63 | * @param version the version to fallback on when finding a conflict. Default is {@link Version#CURRENT}. | |
64 | */ | |
65 | 0 | public void setFallbackOnConflict(Version version) |
66 | { | |
67 | 0 | put(KEY_FALLBACKONCONFLICT, version); |
68 | } | |
69 | ||
70 | /** | |
71 | * @return the version to fallback on when finding a conflict. Default is {@link Version#CURRENT}. | |
72 | */ | |
73 | 0 | public Version getFallbackOnConflict() |
74 | { | |
75 | // Default is Version.NEXT | |
76 | 0 | return containsKey(KEY_FALLBACKONCONFLICT) ? (Version) get(KEY_FALLBACKONCONFLICT) : Version.CURRENT; |
77 | } | |
78 | } |