| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2013, 2017 Red Hat, Inc. and others |
| 3 |
* |
| 4 |
* This program and the accompanying materials |
| 5 |
* are made available under the terms of the Eclipse Public License 2.0 |
| 6 |
* which accompanies this distribution, and is available at |
| 7 |
* https://www.eclipse.org/legal/epl-2.0/ |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: EPL-2.0 |
| 10 |
* |
| 11 |
* Contributors: |
| 12 |
* Red Hat, Inc. - initial API and implementation |
| 13 |
*******************************************************************************/ |
| 14 |
package org.eclipse.equinox.p2.operations; |
| 15 |
|
| 16 |
import java.util.ArrayList; |
| 17 |
import java.util.Collection; |
| 18 |
|
| 19 |
/** |
| 20 |
* <p> |
| 21 |
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as |
| 22 |
* part of a work in progress. There is no guarantee that this API will |
| 23 |
* work or that it will remain the same. Please do not use this API without |
| 24 |
* consulting with the p2 team. |
| 25 |
* </p> |
| 26 |
* @since 2.3 |
| 27 |
* @noreference |
| 28 |
*/ |
| 29 |
public class RemedyConfig { |
| 30 |
|
| 31 |
public boolean allowInstalledUpdate = false; |
| 32 |
public boolean allowInstalledRemoval = false; |
| 33 |
public boolean allowDifferentVersion = false; |
| 34 |
public boolean allowPartialInstall = false; |
| 35 |
|
| 36 |
public RemedyConfig() { |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
private RemedyConfig(boolean allowPartialInstall, boolean allowDifferentVersion, boolean allowInstalledUpdate, boolean allowInstalledRemoval) { |
| 41 |
this.allowDifferentVersion = allowDifferentVersion; |
| 42 |
this.allowInstalledRemoval = allowInstalledRemoval; |
| 43 |
this.allowInstalledUpdate = allowInstalledUpdate; |
| 44 |
this.allowPartialInstall = allowPartialInstall; |
| 45 |
} |
| 46 |
|
| 47 |
public static RemedyConfig[] getCheckForUpdateRemedyConfigs() { |
| 48 |
return new RemedyConfig[] {new RemedyConfig(false, true, true, false)}; |
| 49 |
} |
| 50 |
|
| 51 |
public static RemedyConfig[] getAllRemedyConfigs() { |
| 52 |
Collection<RemedyConfig> remedyConfigs = new ArrayList<>(); |
| 53 |
int allMasks = (1 << 4); |
| 54 |
for (int i = 1; i < allMasks; i++) { |
| 55 |
RemedyConfig remedyConfig = new RemedyConfig(); |
| 56 |
for (int j = 0; j < 4; j++) { |
| 57 |
if ((i & (1 << j)) > 0) { |
| 58 |
switch (j) { |
| 59 |
case 0 : |
| 60 |
remedyConfig.allowPartialInstall = true; |
| 61 |
break; |
| 62 |
case 1 : |
| 63 |
remedyConfig.allowDifferentVersion = true; |
| 64 |
break; |
| 65 |
case 2 : |
| 66 |
remedyConfig.allowInstalledUpdate = true; |
| 67 |
break; |
| 68 |
case 3 : |
| 69 |
remedyConfig.allowInstalledRemoval = true; |
| 70 |
break; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
} |
| 75 |
remedyConfigs.add(remedyConfig); |
| 76 |
} |
| 77 |
RemedyConfig[] test = remedyConfigs.toArray(new RemedyConfig[remedyConfigs.size()]); |
| 78 |
return test; |
| 79 |
} |
| 80 |
} |