src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/PackageProperty.java
author herrick
Fri, 08 Nov 2019 14:53:03 -0500
branchJDK-8200758-branch
changeset 58994 b09ba68c6a19
parent 58791 src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java@fca9cb5f4953
permissions -rw-r--r--
8233636 : Make jpackage an incubator and remove tool provider implementation Reviewed-by: asemenyuk, almatvee, kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58791
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     1
/*
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     4
 *
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    10
 *
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    15
 * accompanied this code).
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    16
 *
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    20
 *
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    23
 * questions.
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    24
 */
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    25
58994
b09ba68c6a19 8233636 : Make jpackage an incubator and remove tool provider implementation
herrick
parents: 58791
diff changeset
    26
package jdk.incubator.jpackage.internal;
58791
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    27
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    28
import java.text.MessageFormat;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    29
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    30
final class PackageProperty {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    31
    /**
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    32
     * Constructor
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    33
     *
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    34
     * @param name property name
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    35
     * @param expectedValue expected property value
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    36
     * @param substString substitution string to be placed in resource file to
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    37
     * be replaced with the expected property value by jpackage at package build
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    38
     * time
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    39
     * @param customResource name of custom resource from resource directory in
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    40
     * which this package property can be set
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    41
     */
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    42
    PackageProperty(String name, String expectedValue, String substString,
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    43
            String customResource) {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    44
        this.name = name;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    45
        this.expectedValue = expectedValue;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    46
        this.substString = substString;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    47
        this.customResource = customResource;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    48
    }
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    49
    
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    50
    ConfigException verifyValue(String actualValue) {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    51
        if (expectedValue.equals(actualValue)) {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    52
            return null;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    53
        }
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    54
        
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    55
        final String advice;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    56
        if (substString != null) {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    57
            advice = MessageFormat.format(I18N.getString(
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    58
                    "error.unexpected-package-property.advice"), substString,
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    59
                    actualValue, name, customResource);
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    60
        } else {
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    61
            advice = MessageFormat.format(I18N.getString(
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    62
                    "error.unexpected-default-package-property.advice"), name,
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    63
                    customResource);
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    64
        }
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    65
        
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    66
        return new ConfigException(MessageFormat.format(I18N.getString(
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    67
                "error.unexpected-package-property"), name,
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    68
                expectedValue, actualValue, customResource, substString), advice);
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    69
    }
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    70
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    71
    final String name;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    72
    private final String expectedValue;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    73
    private final String substString;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    74
    private final String customResource;
fca9cb5f4953 8230612: Debian packaging ignores version and release in custom control file
herrick
parents:
diff changeset
    75
}