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