Skip to main content
summaryrefslogtreecommitdiffstats
blob: 89a18168c14718f663ddd24f572015fa8c871227 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
 * Copyright (c) 2013, 2017 Red Hat, Inc. and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 *  Contributors:
 *     Red Hat, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.operations;

import java.util.ArrayList;
import java.util.Collection;

/**
 * <p>
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
 * part of a work in progress. There is no guarantee that this API will
 * work or that it will remain the same. Please do not use this API without
 * consulting with the p2 team.
 * </p>
 * @since 2.3
 * @noreference
 */
public class RemedyConfig {

	public boolean allowInstalledUpdate = false;
	public boolean allowInstalledRemoval = false;
	public boolean allowDifferentVersion = false;
	public boolean allowPartialInstall = false;

	public RemedyConfig() {

	}

	private RemedyConfig(boolean allowPartialInstall, boolean allowDifferentVersion, boolean allowInstalledUpdate, boolean allowInstalledRemoval) {
		this.allowDifferentVersion = allowDifferentVersion;
		this.allowInstalledRemoval = allowInstalledRemoval;
		this.allowInstalledUpdate = allowInstalledUpdate;
		this.allowPartialInstall = allowPartialInstall;
	}

	public static RemedyConfig[] getCheckForUpdateRemedyConfigs() {
		return new RemedyConfig[] {new RemedyConfig(false, true, true, false)};
	}

	public static RemedyConfig[] getAllRemedyConfigs() {
		Collection<RemedyConfig> remedyConfigs = new ArrayList<>();
		int allMasks = (1 << 4);
		for (int i = 1; i < allMasks; i++) {
			RemedyConfig remedyConfig = new RemedyConfig();
			for (int j = 0; j < 4; j++) {
				if ((i & (1 << j)) > 0) {
					switch (j) {
						case 0 :
							remedyConfig.allowPartialInstall = true;
							break;
						case 1 :
							remedyConfig.allowDifferentVersion = true;
							break;
						case 2 :
							remedyConfig.allowInstalledUpdate = true;
							break;
						case 3 :
							remedyConfig.allowInstalledRemoval = true;
							break;
					}
				}

			}
			remedyConfigs.add(remedyConfig);
		}
		RemedyConfig[] test = remedyConfigs.toArray(new RemedyConfig[remedyConfigs.size()]);
		return test;
	}
}

Back to the top