]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductState.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore.server.environment / src / org / simantics / db / procore / server / environment / windows / ProductState.java
1 /*******************************************************************************\r
2  * Copyright (c) 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.procore.server.environment.windows;\r
13 \r
14 /**\r
15  * The possible return values of Win32 API call MsiQueryProductState enumerated.\r
16  * \r
17  * @author Tuukka Lehtonen\r
18  */\r
19 public enum ProductState {\r
20 \r
21     /**\r
22      * An invalid parameter was passed to the function.\r
23      */\r
24     INVALIDARG(-2),\r
25 \r
26     /**\r
27      * The product is not advertised or installed.\r
28      */\r
29     UNKNOWN(-1),\r
30 \r
31     /**\r
32      * Indicates invocation of {@link Msi#MsiQueryProductState(String)} failed.\r
33      */\r
34     FAILED(0),\r
35 \r
36     /**\r
37      * The product is advertised but not installed.\r
38      */\r
39     ADVERTISED(1),\r
40 \r
41     /**\r
42      * The product is installed for a different user.\r
43      */\r
44     ABSENT(2),\r
45 \r
46     /**\r
47      * The product is installed for a different user.\r
48      */\r
49     DEFAULT(5);\r
50 \r
51     int code;\r
52 \r
53     ProductState(int code) {\r
54         this.code = code;\r
55     }\r
56 \r
57     public static ProductState of(int code) {\r
58         switch (code) {\r
59             case -2: return INVALIDARG;\r
60             case -1: return UNKNOWN;\r
61             case 0: return FAILED;\r
62             case 1: return ADVERTISED;\r
63             case 2: return ABSENT;\r
64             case 5: return DEFAULT;\r
65             default: throw new IllegalArgumentException("unrecognized product install state return code: " + code);\r
66         }\r
67     }\r
68 \r
69     @Override\r
70     public String toString() {\r
71         return name() + "(" + code + ")";\r
72     }\r
73 \r
74 }\r