esult = 31 * result + hostname.toUpperCase(Locale.ENGLISH).hashCode();

package javax.net.ssl;

import java.net.IDN;
import java.nio.ByteBuffer;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharacterCodingException;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * Instances of this class represent a server name of type
 * {@link StandardConstants#SNI_HOST_NAME host_name} in a Server Name
 * Indication (SNI) extension.
 *

 * As described in section 3, "Server Name Indication", of
 * TLS Extensions (RFC 6066),
 * "HostName" contains the fully qualified DNS hostname of the server, as
 * understood by the client.  The encoded server name value of a hostname is
 * represented as a byte string using ASCII encoding without a trailing dot.
 * This allows the support of Internationalized Domain Names (IDN) through
 * the use of A-labels (the ASCII-Compatible Encoding (ACE) form of a valid
 * string of Internationalized Domain Names for Applications (IDNA)) defined
 * in RFC 5890.
 *

 * Note that {@code SNIHostName} objects are immutable.
 *
 * @see SNIServerName
 * @see StandardConstants#SNI_HOST_NAME
 *
 * @since 1.8
 */
public final class SNIHostName extends SNIServerName {

    // the decoded string value of the server name
    private final String hostname;

    /**
     * Creates an {@code SNIHostName} using the specified hostname.
     *

     * Note that per RFC 6066,
     * the encoded server name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  In this method,
     * {@code hostname} can be a user-friendly Internationalized Domain Name
     * (IDN).  {@link IDN#toASCII(String, int)} is used to enforce the
     * restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123) and
     * translate the {@code hostname} into ASCII Compatible Encoding (ACE), as:
     *

     *     IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
     *

     *

     * The {@code hostname} argument is illegal if it:
     *

     *
 {@code hostname} is empty,

     *
 {@code hostname} ends with a trailing dot,

     *
 {@code hostname} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     * @param  hostname
     *         the hostname of this server name
     *
     * @throws NullPointerException if {@code hostname} is {@code null}
     * @throws IllegalArgumentException if {@code hostname} is illegal
     */
    public SNIHostName(String hostname) {
        // IllegalArgumentException will be thrown if {@code hostname} is
        // not a valid IDN.
        super(StandardConstants.SNI_HOST_NAME, (hostname = IDN.toASCII(Objects.requireNonNull(hostname, "Server name value of host_name cannot be null"), IDN.USE_STD3_ASCII_RULES)).getBytes(StandardCharsets.US_ASCII));
        this.hostname = hostname;
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Creates an {@code SNIHostName} using the specified encoded value.
     *

     * This method is normally used to parse the encoded name value in a
     * requested SNI extension.
     *

     * Per RFC 6066,
     * the encoded name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  However, in the previous
     * version of the SNI extension (
     * RFC 4366),
     * the encoded hostname is represented as a byte string using UTF-8
     * encoding.  For the purpose of version tolerance, this method allows
     * that the charset of {@code encoded} argument can be
     * {@link StandardCharsets#UTF_8}, as well as
     * {@link StandardCharsets#US_ASCII}.  {@link IDN#toASCII(String)} is used
     * to translate the {@code encoded} argument into ASCII Compatible
     * Encoding (ACE) hostname.
     *

     * It is strongly recommended that this constructor is only used to parse
     * the encoded name value in a requested SNI extension.  Otherwise, to
     * comply with RFC 6066,
     * please always use {@link StandardCharsets#US_ASCII}-compliant charset
     * and enforce the restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123)
     * for {@code encoded} argument, or use
     * {@link SNIHostName#SNIHostName(String)} instead.
     *

     * The {@code encoded} argument is illegal if it:
     *

     *
 {@code encoded} is empty,

     *
 {@code encoded} ends with a trailing dot,

     *
 {@code encoded} is not encoded in
     *      {@link StandardCharsets#US_ASCII} or
     *      {@link StandardCharsets#UTF_8}-compliant charset,

     *
 {@code encoded} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     *
     *

     * Note that the {@code encoded} byte array is cloned
     * to protect against subsequent modification.
     *
     * @param  encoded
     *         the encoded hostname of this server name
     *
     * @throws NullPointerException if {@code encoded} is {@code null}
     * @throws IllegalArgumentException if {@code encoded} is illegal
     */
    public SNIHostName(byte[] encoded) {
        // NullPointerException will be thrown if {@code encoded} is null
        super(StandardConstants.SNI_HOST_NAME, encoded);
        // Compliance: RFC 4366 requires that the hostname is represented
        // as a byte string using UTF_8 encoding [UTF8]
        try {
            // Please don't use {@link String} constructors because they
            // do not report coding errors.
            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
            this.hostname = IDN.toASCII(decoder.decode(ByteBuffer.wrap(encoded)).toString(), IDN.USE_STD3_ASCII_RULES);
        } catch (RuntimeException | CharacterCodingException e) {
            throw new IllegalArgumentException("The encoded server name value is invalid", e);
        }
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Returns the {@link StandardCharsets#US_ASCII}-compliant hostname of
     * this {@code SNIHostName} object.
     *

     * Note that, per
     * RFC 6066, the
     * returned hostname may be an internationalized domain name that
     * contains A-labels. See
     * RFC 5890
     * for more information about the detailed A-label specification.
     *
     * @return the {@link StandardCharsets#US_ASCII}-compliant hostname
     *         of this {@code SNIHostName} object
     */
    public String getAsciiName() {
        return hostname;
    }

    /**
     * Compares this server name to the specified object.
     *

     * Per RFC 6066, DNS
     * hostnames are case-insensitive.  Two server hostnames are equal if,
     * and only if, they have the same name type, and the hostnames are
     * equal in a case-independent comparison.
     *
     * @param  other
     *         the other server name object to compare with.
     * @return true if, and only if, the {@code other} is considered
     *         equal to this instance
     */
    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof SNIHostName) {
            return hostname.equalsIgnoreCase(((SNIHostName) other).hostname);
        }
        return false;
    }

    /**
     * Returns a hash code value for this {@code SNIHostName}.
     *

     * The hash code value is generated using the case-insensitive hostname
     * of this {@code SNIHostName}.
     *
     * @return a hash code value for this {@code SNIHostName}.
     */
    @Override
    public int hashCode() {
        // 17/31: prime number to decrease collisions
        int result = 17;
        r

return result;
    }

    /**
     * Returns a string representation of the object, including the DNS
     * hostname in this {@code SNIHostName} object.
     *

     * The exact details of the representation are unspecified and subject
     * to change, but the following may be regarded as typical:
     *

     *     "type=host_name (0), value={@literal <hostname>}"
     *

     * The "{@literal <hostname>}" is an ASCII representation of the hostname,
     * which may contains A-labels.  For example, a returned value of an pseudo
     * hostname may look like:
     *

     *     "type=host_name (0), value=www.example.com"
     *

     * or
     *

     *     "type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
     *

     *

     * Please NOTE that the exact details of the representation are unspecified
     * and subject to change.
     *
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "type=host_name (0), value=" + hostname;
    }

    /**
     * Creates an {@link SNIMatcher} object for {@code SNIHostName}s.
     *

     * This method can be used by a server to verify the acceptable
     * {@code SNIHostName}s.  For example,
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.com");
     *

     * will accept the hostname "www.example.com".
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
     *

     * will accept hostnames "www.example.com" and "www.example.org".
     *
     * @param  regex
     *         the
     *         regular expression pattern
     *         representing the hostname(s) to match
     * @return a {@code SNIMatcher} object for {@code SNIHostName}s
     * @throws NullPointerException if {@code regex} is
     *         {@code null}
     * @throws PatternSyntaxException if the regular expression's
     *         syntax is invalid
     */
    public static SNIMatcher createSNIMatcher(String regex) {
        if (regex == null) {
            throw new NullPointerException("The regular expression cannot be null");
        }
        return new SNIHostNameMatcher(regex);
    }

    // check the validity of the string hostname
    private void checkHostName() {
        if (hostname.isEmpty()) {
            throw new IllegalArgumentException("Server name value of host_name cannot be empty");
        }
        if (hostname.endsWith(".")) {
            throw new IllegalArgumentException("Server name value of host_name cannot have the trailing dot");
        }
    }

    private static final class SNIHostNameMatcher extends SNIMatcher {

        // the compiled representation of a regular expression.
        private final Pattern pattern;

        /**
         * Creates an SNIHostNameMatcher object.
         *
         * @param  regex
         *         the
         *         regular expression pattern
         *         representing the hostname(s) to match
         * @throws NullPointerException if {@code regex} is
         *         {@code null}
         * @throws PatternSyntaxException if the regular expression's syntax
         *         is invalid
         */
        SNIHostNameMatcher(String regex) {
            super(StandardConstants.SNI_HOST_NAME);
            pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        }

        /**
         * Attempts to match the given {@link SNIServerName}.
         *
         * @param  serverName
         *         the {@link SNIServerName} instance on which this matcher
         *         performs match operations
         *
         * @return {@code true} if, and only if, the matcher matches the
         *         given {@code serverName}
         *
         * @throws NullPointerException if {@code serverName} is {@code null}
         * @throws IllegalArgumentException if {@code serverName} is
         *         not of {@code StandardConstants#SNI_HOST_NAME} type
         *
         * @see SNIServerName
         */
        @Override
        public boolean matches(SNIServerName serverName) {
            if (serverName == null) {
                throw new NullPointerException("The SNIServerName argument cannot be null");
            }
            SNIHostName hostname;
            if (!(serverName instanceof SNIHostName)) {
                if (serverName.getType() != StandardConstants.SNI_HOST_NAME) {
                    throw new IllegalArgumentException("The server name type is not host_name");
                }
                try {
                    hostname = new SNIHostName(serverName.getEncoded());
                } catch (NullPointerException | IllegalArgumentException e) {
                    return false;
                }
            } else {
                hostname = (SNIHostName) serverName;
            }
            // Let's first try the ascii name matching
            String asciiName = hostname.getAsciiName();
            if (pattern.matcher(asciiName).matches()) {
                return true;
            }
            // May be an internationalized domain name, check the Unicode
            return pattern.matcher(IDN.toUnicode(asciiName)).matches();
        }
    }
}


public static SNIMatcher createSNIMatcher(String regex) {
        if (regex == null) {
            throw new NullPointerException("The regular expression cannot be null");
        }
        return new SNIHostNameMatcher(regex);
    }

package javax.net.ssl;

import java.net.IDN;
import java.nio.ByteBuffer;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharacterCodingException;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * Instances of this class represent a server name of type
 * {@link StandardConstants#SNI_HOST_NAME host_name} in a Server Name
 * Indication (SNI) extension.
 *

 * As described in section 3, "Server Name Indication", of
 * TLS Extensions (RFC 6066),
 * "HostName" contains the fully qualified DNS hostname of the server, as
 * understood by the client.  The encoded server name value of a hostname is
 * represented as a byte string using ASCII encoding without a trailing dot.
 * This allows the support of Internationalized Domain Names (IDN) through
 * the use of A-labels (the ASCII-Compatible Encoding (ACE) form of a valid
 * string of Internationalized Domain Names for Applications (IDNA)) defined
 * in RFC 5890.
 *

 * Note that {@code SNIHostName} objects are immutable.
 *
 * @see SNIServerName
 * @see StandardConstants#SNI_HOST_NAME
 *
 * @since 1.8
 */
public final class SNIHostName extends SNIServerName {

    // the decoded string value of the server name
    private final String hostname;

    /**
     * Creates an {@code SNIHostName} using the specified hostname.
     *

     * Note that per RFC 6066,
     * the encoded server name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  In this method,
     * {@code hostname} can be a user-friendly Internationalized Domain Name
     * (IDN).  {@link IDN#toASCII(String, int)} is used to enforce the
     * restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123) and
     * translate the {@code hostname} into ASCII Compatible Encoding (ACE), as:
     *

     *     IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
     *

     *

     * The {@code hostname} argument is illegal if it:
     *

     *
 {@code hostname} is empty,

     *
 {@code hostname} ends with a trailing dot,

     *
 {@code hostname} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     * @param  hostname
     *         the hostname of this server name
     *
     * @throws NullPointerException if {@code hostname} is {@code null}
     * @throws IllegalArgumentException if {@code hostname} is illegal
     */
    public SNIHostName(String hostname) {
        // IllegalArgumentException will be thrown if {@code hostname} is
        // not a valid IDN.
        super(StandardConstants.SNI_HOST_NAME, (hostname = IDN.toASCII(Objects.requireNonNull(hostname, "Server name value of host_name cannot be null"), IDN.USE_STD3_ASCII_RULES)).getBytes(StandardCharsets.US_ASCII));
        this.hostname = hostname;
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Creates an {@code SNIHostName} using the specified encoded value.
     *

     * This method is normally used to parse the encoded name value in a
     * requested SNI extension.
     *

     * Per RFC 6066,
     * the encoded name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  However, in the previous
     * version of the SNI extension (
     * RFC 4366),
     * the encoded hostname is represented as a byte string using UTF-8
     * encoding.  For the purpose of version tolerance, this method allows
     * that the charset of {@code encoded} argument can be
     * {@link StandardCharsets#UTF_8}, as well as
     * {@link StandardCharsets#US_ASCII}.  {@link IDN#toASCII(String)} is used
     * to translate the {@code encoded} argument into ASCII Compatible
     * Encoding (ACE) hostname.
     *

     * It is strongly recommended that this constructor is only used to parse
     * the encoded name value in a requested SNI extension.  Otherwise, to
     * comply with RFC 6066,
     * please always use {@link StandardCharsets#US_ASCII}-compliant charset
     * and enforce the restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123)
     * for {@code encoded} argument, or use
     * {@link SNIHostName#SNIHostName(String)} instead.
     *

     * The {@code encoded} argument is illegal if it:
     *

     *
 {@code encoded} is empty,

     *
 {@code encoded} ends with a trailing dot,

     *
 {@code encoded} is not encoded in
     *      {@link StandardCharsets#US_ASCII} or
     *      {@link StandardCharsets#UTF_8}-compliant charset,

     *
 {@code encoded} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     *
     *

     * Note that the {@code encoded} byte array is cloned
     * to protect against subsequent modification.
     *
     * @param  encoded
     *         the encoded hostname of this server name
     *
     * @throws NullPointerException if {@code encoded} is {@code null}
     * @throws IllegalArgumentException if {@code encoded} is illegal
     */
    public SNIHostName(byte[] encoded) {
        // NullPointerException will be thrown if {@code encoded} is null
        super(StandardConstants.SNI_HOST_NAME, encoded);
        // Compliance: RFC 4366 requires that the hostname is represented
        // as a byte string using UTF_8 encoding [UTF8]
        try {
            // Please don't use {@link String} constructors because they
            // do not report coding errors.
            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
            this.hostname = IDN.toASCII(decoder.decode(ByteBuffer.wrap(encoded)).toString(), IDN.USE_STD3_ASCII_RULES);
        } catch (RuntimeException | CharacterCodingException e) {
            throw new IllegalArgumentException("The encoded server name value is invalid", e);
        }
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Returns the {@link StandardCharsets#US_ASCII}-compliant hostname of
     * this {@code SNIHostName} object.
     *

     * Note that, per
     * RFC 6066, the
     * returned hostname may be an internationalized domain name that
     * contains A-labels. See
     * RFC 5890
     * for more information about the detailed A-label specification.
     *
     * @return the {@link StandardCharsets#US_ASCII}-compliant hostname
     *         of this {@code SNIHostName} object
     */
    public String getAsciiName() {
        return hostname;
    }

    /**
     * Compares this server name to the specified object.
     *

     * Per RFC 6066, DNS
     * hostnames are case-insensitive.  Two server hostnames are equal if,
     * and only if, they have the same name type, and the hostnames are
     * equal in a case-independent comparison.
     *
     * @param  other
     *         the other server name object to compare with.
     * @return true if, and only if, the {@code other} is considered
     *         equal to this instance
     */
    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof SNIHostName) {
            return hostname.equalsIgnoreCase(((SNIHostName) other).hostname);
        }
        return false;
    }

    /**
     * Returns a hash code value for this {@code SNIHostName}.
     *

     * The hash code value is generated using the case-insensitive hostname
     * of this {@code SNIHostName}.
     *
     * @return a hash code value for this {@code SNIHostName}.
     */
    @Override
    public int hashCode() {
        // 17/31: prime number to decrease collisions
        int result = 17;
        result = 31 * result + hostname.toUpperCase(Locale.ENGLISH).hashCode();
        return result;
    }

    /**
     * Returns a string representation of the object, including the DNS
     * hostname in this {@code SNIHostName} object.
     *

     * The exact details of the representation are unspecified and subject
     * to change, but the following may be regarded as typical:
     *

     *     "type=host_name (0), value={@literal <hostname>}"
     *

     * The "{@literal <hostname>}" is an ASCII representation of the hostname,
     * which may contains A-labels.  For example, a returned value of an pseudo
     * hostname may look like:
     *

     *     "type=host_name (0), value=www.example.com"
     *

     * or
     *

     *     "type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
     *

     *

     * Please NOTE that the exact details of the representation are unspecified
     * and subject to change.
     *
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "type=host_name (0), value=" + hostname;
    }

    /**
     * Creates an {@link SNIMatcher} object for {@code SNIHostName}s.
     *

     * This method can be used by a server to verify the acceptable
     * {@code SNIHostName}s.  For example,
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.com");
     *

     * will accept the hostname "www.example.com".
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
     *

     * will accept hostnames "www.example.com" and "www.example.org".
     *
     * @param  regex
     *         the
     *         regular expression pattern
     *         representing the hostname(s) to match
     * @return a {@code SNIMatcher} object for {@code SNIHostName}s
     * @throws NullPointerException if {@code regex} is
     *         {@code null}
     * @throws PatternSyntaxException if the regular expression's
     *         syntax is invalid
     */

// check the validity of the string hostname
    private void checkHostName() {
        if (hostname.isEmpty()) {
            throw new IllegalArgumentException("Server name value of host_name cannot be empty");
        }
        if (hostname.endsWith(".")) {
            throw new IllegalArgumentException("Server name value of host_name cannot have the trailing dot");
        }
    }

    private static final class SNIHostNameMatcher extends SNIMatcher {

        // the compiled representation of a regular expression.
        private final Pattern pattern;

        /**
         * Creates an SNIHostNameMatcher object.
         *
         * @param  regex
         *         the
         *         regular expression pattern
         *         representing the hostname(s) to match
         * @throws NullPointerException if {@code regex} is
         *         {@code null}
         * @throws PatternSyntaxException if the regular expression's syntax
         *         is invalid
         */
        SNIHostNameMatcher(String regex) {
            super(StandardConstants.SNI_HOST_NAME);
            pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        }

        /**
         * Attempts to match the given {@link SNIServerName}.
         *
         * @param  serverName
         *         the {@link SNIServerName} instance on which this matcher
         *         performs match operations
         *
         * @return {@code true} if, and only if, the matcher matches the
         *         given {@code serverName}
         *
         * @throws NullPointerException if {@code serverName} is {@code null}
         * @throws IllegalArgumentException if {@code serverName} is
         *         not of {@code StandardConstants#SNI_HOST_NAME} type
         *
         * @see SNIServerName
         */
        @Override
        public boolean matches(SNIServerName serverName) {
            if (serverName == null) {
                throw new NullPointerException("The SNIServerName argument cannot be null");
            }
            SNIHostName hostname;
            if (!(serverName instanceof SNIHostName)) {
                if (serverName.getType() != StandardConstants.SNI_HOST_NAME) {
                    throw new IllegalArgumentException("The server name type is not host_name");
                }
                try {
                    hostname = new SNIHostName(serverName.getEncoded());
                } catch (NullPointerException | IllegalArgumentException e) {
                    return false;
                }
            } else {
                hostname = (SNIHostName) serverName;
            }
            // Let's first try the ascii name matching
            String asciiName = hostname.getAsciiName();
            if (pattern.matcher(asciiName).matches()) {
                return true;
            }
            // May be an internationalized domain name, check the Unicode
            return pattern.matcher(IDN.toUnicode(asciiName)).matches();
        }
    }
}


try {
                    hostname = new SNIHostName(serverName.getEncoded());
                } catch (NullPointerException | IllegalArgumentException e) {
                    return false;
                }

package javax.net.ssl;

import java.net.IDN;
import java.nio.ByteBuffer;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharacterCodingException;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * Instances of this class represent a server name of type
 * {@link StandardConstants#SNI_HOST_NAME host_name} in a Server Name
 * Indication (SNI) extension.
 *

 * As described in section 3, "Server Name Indication", of
 * TLS Extensions (RFC 6066),
 * "HostName" contains the fully qualified DNS hostname of the server, as
 * understood by the client.  The encoded server name value of a hostname is
 * represented as a byte string using ASCII encoding without a trailing dot.
 * This allows the support of Internationalized Domain Names (IDN) through
 * the use of A-labels (the ASCII-Compatible Encoding (ACE) form of a valid
 * string of Internationalized Domain Names for Applications (IDNA)) defined
 * in RFC 5890.
 *

 * Note that {@code SNIHostName} objects are immutable.
 *
 * @see SNIServerName
 * @see StandardConstants#SNI_HOST_NAME
 *
 * @since 1.8
 */
public final class SNIHostName extends SNIServerName {

    // the decoded string value of the server name
    private final String hostname;

    /**
     * Creates an {@code SNIHostName} using the specified hostname.
     *

     * Note that per RFC 6066,
     * the encoded server name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  In this method,
     * {@code hostname} can be a user-friendly Internationalized Domain Name
     * (IDN).  {@link IDN#toASCII(String, int)} is used to enforce the
     * restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123) and
     * translate the {@code hostname} into ASCII Compatible Encoding (ACE), as:
     *

     *     IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
     *

     *

     * The {@code hostname} argument is illegal if it:
     *

     *
 {@code hostname} is empty,

     *
 {@code hostname} ends with a trailing dot,

     *
 {@code hostname} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     * @param  hostname
     *         the hostname of this server name
     *
     * @throws NullPointerException if {@code hostname} is {@code null}
     * @throws IllegalArgumentException if {@code hostname} is illegal
     */
    public SNIHostName(String hostname) {
        // IllegalArgumentException will be thrown if {@code hostname} is
        // not a valid IDN.
        super(StandardConstants.SNI_HOST_NAME, (hostname = IDN.toASCII(Objects.requireNonNull(hostname, "Server name value of host_name cannot be null"), IDN.USE_STD3_ASCII_RULES)).getBytes(StandardCharsets.US_ASCII));
        this.hostname = hostname;
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Creates an {@code SNIHostName} using the specified encoded value.
     *

     * This method is normally used to parse the encoded name value in a
     * requested SNI extension.
     *

     * Per RFC 6066,
     * the encoded name value of a hostname is
     * {@link StandardCharsets#US_ASCII}-compliant.  However, in the previous
     * version of the SNI extension (
     * RFC 4366),
     * the encoded hostname is represented as a byte string using UTF-8
     * encoding.  For the purpose of version tolerance, this method allows
     * that the charset of {@code encoded} argument can be
     * {@link StandardCharsets#UTF_8}, as well as
     * {@link StandardCharsets#US_ASCII}.  {@link IDN#toASCII(String)} is used
     * to translate the {@code encoded} argument into ASCII Compatible
     * Encoding (ACE) hostname.
     *

     * It is strongly recommended that this constructor is only used to parse
     * the encoded name value in a requested SNI extension.  Otherwise, to
     * comply with RFC 6066,
     * please always use {@link StandardCharsets#US_ASCII}-compliant charset
     * and enforce the restrictions on ASCII characters in hostnames (see
     * RFC 3490,
     * RFC 1122,
     * RFC 1123)
     * for {@code encoded} argument, or use
     * {@link SNIHostName#SNIHostName(String)} instead.
     *

     * The {@code encoded} argument is illegal if it:
     *

     *
 {@code encoded} is empty,

     *
 {@code encoded} ends with a trailing dot,

     *
 {@code encoded} is not encoded in
     *      {@link StandardCharsets#US_ASCII} or
     *      {@link StandardCharsets#UTF_8}-compliant charset,

     *
 {@code encoded} is not a valid Internationalized
     *      Domain Name (IDN) compliant with the RFC 3490 specification.

     *

     *
     *

     * Note that the {@code encoded} byte array is cloned
     * to protect against subsequent modification.
     *
     * @param  encoded
     *         the encoded hostname of this server name
     *
     * @throws NullPointerException if {@code encoded} is {@code null}
     * @throws IllegalArgumentException if {@code encoded} is illegal
     */
    public SNIHostName(byte[] encoded) {
        // NullPointerException will be thrown if {@code encoded} is null
        super(StandardConstants.SNI_HOST_NAME, encoded);
        // Compliance: RFC 4366 requires that the hostname is represented
        // as a byte string using UTF_8 encoding [UTF8]
        try {
            // Please don't use {@link String} constructors because they
            // do not report coding errors.
            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
            this.hostname = IDN.toASCII(decoder.decode(ByteBuffer.wrap(encoded)).toString(), IDN.USE_STD3_ASCII_RULES);
        } catch (RuntimeException | CharacterCodingException e) {
            throw new IllegalArgumentException("The encoded server name value is invalid", e);
        }
        // check the validity of the string hostname
        checkHostName();
    }

    /**
     * Returns the {@link StandardCharsets#US_ASCII}-compliant hostname of
     * this {@code SNIHostName} object.
     *

     * Note that, per
     * RFC 6066, the
     * returned hostname may be an internationalized domain name that
     * contains A-labels. See
     * RFC 5890
     * for more information about the detailed A-label specification.
     *
     * @return the {@link StandardCharsets#US_ASCII}-compliant hostname
     *         of this {@code SNIHostName} object
     */
    public String getAsciiName() {
        return hostname;
    }

    /**
     * Compares this server name to the specified object.
     *

     * Per RFC 6066, DNS
     * hostnames are case-insensitive.  Two server hostnames are equal if,
     * and only if, they have the same name type, and the hostnames are
     * equal in a case-independent comparison.
     *
     * @param  other
     *         the other server name object to compare with.
     * @return true if, and only if, the {@code other} is considered
     *         equal to this instance
     */
    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof SNIHostName) {
            return hostname.equalsIgnoreCase(((SNIHostName) other).hostname);
        }
        return false;
    }

    /**
     * Returns a hash code value for this {@code SNIHostName}.
     *

     * The hash code value is generated using the case-insensitive hostname
     * of this {@code SNIHostName}.
     *
     * @return a hash code value for this {@code SNIHostName}.
     */
    @Override
    public int hashCode() {
        // 17/31: prime number to decrease collisions
        int result = 17;
        result = 31 * result + hostname.toUpperCase(Locale.ENGLISH).hashCode();
        return result;
    }

    /**
     * Returns a string representation of the object, including the DNS
     * hostname in this {@code SNIHostName} object.
     *

     * The exact details of the representation are unspecified and subject
     * to change, but the following may be regarded as typical:
     *

     *     "type=host_name (0), value={@literal <hostname>}"
     *

     * The "{@literal <hostname>}" is an ASCII representation of the hostname,
     * which may contains A-labels.  For example, a returned value of an pseudo
     * hostname may look like:
     *

     *     "type=host_name (0), value=www.example.com"
     *

     * or
     *

     *     "type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
     *

     *

     * Please NOTE that the exact details of the representation are unspecified
     * and subject to change.
     *
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "type=host_name (0), value=" + hostname;
    }

    /**
     * Creates an {@link SNIMatcher} object for {@code SNIHostName}s.
     *

     * This method can be used by a server to verify the acceptable
     * {@code SNIHostName}s.  For example,
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.com");
     *

     * will accept the hostname "www.example.com".
     *

     *     SNIMatcher matcher =
     *         SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
     *

     * will accept hostnames "www.example.com" and "www.example.org".
     *
     * @param  regex
     *         the
     *         regular expression pattern
     *         representing the hostname(s) to match
     * @return a {@code SNIMatcher} object for {@code SNIHostName}s
     * @throws NullPointerException if {@code regex} is
     *         {@code null}
     * @throws PatternSyntaxException if the regular expression's
     *         syntax is invalid
     */
    public static SNIMatcher createSNIMatcher(String regex) {
        if (regex == null) {
            throw new NullPointerException("The regular expression cannot be null");
        }
        return new SNIHostNameMatcher(regex);
    }

    // check the validity of the string hostname
    private void checkHostName() {
        if (hostname.isEmpty()) {
            throw new IllegalArgumentException("Server name value of host_name cannot be empty");
        }
        if (hostname.endsWith(".")) {
            throw new IllegalArgumentException("Server name value of host_name cannot have the trailing dot");
        }
    }

    private static final class SNIHostNameMatcher extends SNIMatcher {

        // the compiled representation of a regular expression.
        private final Pattern pattern;

        /**
         * Creates an SNIHostNameMatcher object.
         *
         * @param  regex
         *         the
         *         regular expression pattern
         *         representing the hostname(s) to match
         * @throws NullPointerException if {@code regex} is
         *         {@code null}
         * @throws PatternSyntaxException if the regular expression's syntax
         *         is invalid
         */
        SNIHostNameMatcher(String regex) {
            super(StandardConstants.SNI_HOST_NAME);
            pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        }

        /**
         * Attempts to match the given {@link SNIServerName}.
         *
         * @param  serverName
         *         the {@link SNIServerName} instance on which this matcher
         *         performs match operations
         *
         * @return {@code true} if, and only if, the matcher matches the
         *         given {@code serverName}
         *
         * @throws NullPointerException if {@code serverName} is {@code null}
         * @throws IllegalArgumentException if {@code serverName} is
         *         not of {@code StandardConstants#SNI_HOST_NAME} type
         *
         * @see SNIServerName
         */
        @Override
        public boolean matches(SNIServerName serverName) {
            if (serverName == null) {
                throw new NullPointerException("The SNIServerName argument cannot be null");
            }
            SNIHostName hostname;
            if (!(serverName instanceof SNIHostName)) {
                if (serverName.getType() != StandardConstants.SNI_HOST_NAME) {
                    throw new IllegalArgumentException("The server name type is not host_name");
                }

            } else {
                hostname = (SNIHostName) serverName;
            }
            // Let's first try the ascii name matching
            String asciiName = hostname.getAsciiName();
            if (pattern.matcher(asciiName).matches()) {
                return true;
            }
            // May be an internationalized domain name, check the Unicode
            return pattern.matcher(IDN.toUnicode(asciiName)).matches();
        }
    }
}


@Override
    public void onCreate(Bundle savedInstanceState)

package com.aphidmobile.flip.demo;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import com.aphidmobile.flip.FlipViewController;
import com.aphidmobile.flip.demo.adapter.TravelAdapter;
import com.aphidmobile.flipview.demo.R;

public class FlipComplexLayoutActivity extends Activity {

    private FlipViewController flipView;

    /**
     * Called when the activity is first created.
     */

{
        super.onCreate(savedInstanceState);
        setTitle(R.string.activity_title);
        flipView = new FlipViewController(this);
        // Use RGB_565 can reduce peak memory usage on large screen device, but it's up to you to choose the best bitmap format
        flipView.setAnimationBitmapFormat(Bitmap.Config.RGB_565);
        flipView.setAdapter(new TravelAdapter(this));
        setContentView(flipView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        flipView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        flipView.onPause();
    }
}


{
        super.onPause();
        flipView.onPause();
    }

package com.aphidmobile.flip.demo;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import com.aphidmobile.flip.FlipViewController;
import com.aphidmobile.flip.demo.adapter.TravelAdapter;
import com.aphidmobile.flipview.demo.R;

public class FlipComplexLayoutActivity extends Activity {

    private FlipViewController flipView;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.activity_title);
        flipView = new FlipViewController(this);
        // Use RGB_565 can reduce peak memory usage on large screen device, but it's up to you to choose the best bitmap format
        flipView.setAnimationBitmapFormat(Bitmap.Config.RGB_565);
        flipView.setAdapter(new TravelAdapter(this));
        setContentView(flipView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        flipView.onResume();
    }

    @Override
    protected void onPause()


package com.aphidmobile.flip.demo;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import com.aphidmobile.flip.FlipViewController;
import com.aphidmobile.flip.demo.adapter.TravelAdapter;
import com.aphidmobile.flipview.demo.R;

public class FlipComplexLayoutActivity extends Activity {

    private FlipViewController flipView;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.activity_title);
        flipView = new FlipVi

        // Use RGB_565 can reduce peak memory usage on large screen device, but it's up to you to choose the best bitmap format
        flipView.setAnimationBitmapFormat(Bitmap.Config.RGB_565);
        flipView.setAdapter(new TravelAdapter(this));
        setContentView(flipView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        flipView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        flipView.onPause();
    }
}


@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.activity_title);
        flipView = new FlipViewController(this);
        // Use RGB_565 can reduce peak memory usage on large screen device, but it's up to you to choose the best bitmap format
        flipView.setAnimationBitmapFormat(Bitmap.Config.RGB_565);
        flipView.setAdapter(new TravelAdapter(this));
        setContentView(flipView);
    }

    @Override
    protected void onResume() {
        super.onResume();
        flipView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        flipView.onPause();
    }
}


package org.apache.gobblin.data.management.version;

import java.util.Set;
import org.apache.hadoop.fs.FileStatus;

/**
 * A {@link FileSystemDatasetVersion} that is aware {@link FileStatus}s or its paths
 */
public interface FileStatusAware {

    /**
     * Get the set of {@link FileStatus}s that are included in this dataset version or the {@link FileStatus} of the dataset
     * version itself (In which case the set has one file status).
     */


private void populateInternalTypeInfo(Class javaClass, QName typeQName, SchemaTypeKey key, TypeInfo.UpdatableTypeInfo typeInfo) throws DeploymentException

package org.apache.geronimo.axis.builder;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
import org.apache.axis.description.ElementDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.geronimo.axis.client.TypeInfo;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.webservices.builder.SchemaTypeKey;
import org.apache.geronimo.webservices.builder.WSDescriptorParser;
import org.apache.openejb.jee.JavaWsdlMapping;
import org.apache.xmlbeans.SchemaParticle;
import org.apache.xmlbeans.SchemaType;
import org.osgi.framework.Bundle;

public class LightweightTypeInfoBuilder implements TypeInfoBuilder {

    private final Bundle cl;

    private final Map schemaTypeKeyToSchemaTypeMap;

    private final Set wrapperElementQNames;

    public LightweightTypeInfoBuilder(Bundle bundle, Map schemaTypeKeyToSchemaTypeMap, Set wrapperElementQNames) {
        this.cl = bundle;
        this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
        this.wrapperElementQNames = wrapperElementQNames;
    }

    public List buildTypeInfo(JavaWsdlMapping mapping) throws DeploymentException {
        List typeInfoList = new ArrayList();
        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iterator.hasNext(); ) {
            SchemaTypeKey key = (SchemaTypeKey) iterator.next();
            if (!key.isElement() && !key.isAnonymous()) {
                QName typeQName = key.getqName();
                String namespace = typeQName.getNamespaceURI();
                String packageName = WSDescriptorParser.getPackageFromNamespace(namespace, mapping);
                String classShortName = typeQName.getLocalPart();
                String className = packageName + "." + classShortName;
                Class clazz = null;
                try {
                    clazz = ClassLoading.loadClass(className, cl);
                } catch (ClassNotFoundException e) {
                    throw new DeploymentException("Could not load java type", e);
                }
                Class serializerFactoryClass = BeanSerializerFactory.class;
                Class deserializerFactoryClass = BeanDeserializerFactory.class;
                if (clazz.isArray()) {
                    serializerFactoryClass = ArraySerializerFactory.class;
                    deserializerFactoryClass = ArrayDeserializerFactory.class;
                }
                TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
                internalTypeInfo.setClazz(clazz);
                internalTypeInfo.setQName(typeQName);
                internalTypeInfo.setSerializerClass(serializerFactoryClass);
                internalTypeInfo.setDeserializerClass(deserializerFactoryClass);
                populateInternalTypeInfo(clazz, typeQName, key, internalTypeInfo);
                typeInfoList.add(internalTypeInfo.buildTypeInfo());
            }
        }
        return typeInfoList;
    }

{
        SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
        if (schemaType == null) {
            throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
        }
        typeInfo.setCanSearchParents(schemaType.getDerivationType() == SchemaType.DT_RESTRICTION);
        Map nameToType = new HashMap();
        if (null == schemaType.getContentModel()) {
        } else if (SchemaParticle.SEQUENCE == schemaType.getContentModel().getParticleType() || SchemaParticle.ALL == schemaType.getContentModel().getParticleType()) {
            SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
            for (int i = 0; i < properties.length; i++) {
                SchemaParticle parameter = properties[i];
                // throw new DeploymentException(parameter.getName() + " is not an element in schema " + schemaType.getName());
                nameToType.put(parameter.getName(), parameter);
            }
        } else if (SchemaParticle.ELEMENT == schemaType.getContentModel().getParticleType()) {
            SchemaParticle parameter = schemaType.getContentModel();
            nameToType.put(parameter.getName(), parameter);
        } else {
            throw new DeploymentException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
        }
        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
        } catch (IntrospectionException e) {
            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
        }
        Map nameToClass = new HashMap();
        for (int i = 0; i < descriptors.length; i++) {
            nameToClass.put(descriptors[i].getName(), descriptors[i].getPropertyType());
        }
        int idx = 0;
        FieldDesc[] fields = new FieldDesc[nameToType.size()];
        typeInfo.setFields(fields);
        for (Iterator iter = nameToType.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iter.next();
            QName fieldQName = (QName) entry.getKey();
            String fieldName = fieldQName.getLocalPart();
            SchemaParticle particle = (SchemaParticle) entry.getValue();
            ElementDesc elementDesc = new ElementDesc();
            elementDesc.setFieldName(fieldName);
            Class javaType = (Class) nameToClass.get(fieldName);
            if (null == javaType) {
                throw new DeploymentException("Field " + fieldName + " is not defined by class " + javaClass.getName());
            }
            elementDesc.setNillable(particle.isNillable());
            elementDesc.setXmlName(fieldQName);
            elementDesc.setXmlType(particle.getType().getName());
            if (javaType.isArray()) {
                elementDesc.setMinOccurs(particle.getIntMinOccurs());
                elementDesc.setMaxOccurs(particle.getIntMaxOccurs());
                // TODO axis seems to have the wrong name for this property based on how it is used
                elementDesc.setMaxOccursUnbounded(particle.getIntMaxOccurs() > 1);
            }
            fields[idx++] = elementDesc;
        }
    }
}


package org.apache.geronimo.axis.builder;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
import org.apache.axis.description.ElementDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.geronimo.axis.client.TypeInfo;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.webservices.builder.SchemaTypeKey;
import org.apache.geronimo.webservices.builder.WSDescriptorParser;
import org.apache.openejb.jee.JavaWsdlMapping;
import org.apache.xmlbeans.SchemaParticle;
import org.apache.xmlbeans.SchemaType;
import org.osgi.framework.Bundle;

public class LightweightTypeInfoBuilder implements TypeInfoBuilder {

    private final Bundle cl;

    private final Map schemaTypeKeyToSchemaTypeMap;

    private final Set wrapperElementQNames;

    public LightweightTypeInfoBuilder(Bundle bundle, Map schemaTypeKeyToSchemaTypeMap, Set wrapperElementQNames) {
        this.cl = bundle;
        this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
        this.wrapperElementQNames = wrapperElementQNames;
    }

    public List buildTypeInfo(JavaWsdlMapping mapping) throws DeploymentException {
        List typeInfoList = new ArrayList();
        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iterator.hasNext(); ) {
            SchemaTypeKey key = (SchemaTypeKey) iterator.next();
            if (!key.isElement() && !key.isAnonymous()) {
                QName typeQName = key.getqName();
                String namespace = typeQName.getNamespaceURI();
                String packageName = WSDescriptorParser.getPackageFromNamespace(namespace, mapping);
                String classShortName = typeQName.getLocalPart();
                String className = packageName + "." + classShortName;
                Class clazz = null;
                try {
                    clazz = ClassLoading.loadClass(className, cl);
                } catch (ClassNotFoundException e) {
                    throw new DeploymentException("Could not load java type", e);
                }
                Class serializerFactoryClass = BeanSerializerFactory.class;
                Class deserializerFactoryClass = BeanDeserializerFactory.class;
                if (clazz.isArray()) {
                    serializerFactoryClass = ArraySerializerFactory.class;
                    deserializerFactoryClass = ArrayDeserializerFactory.class;
                }
                TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
                internalTypeInfo.setClazz(clazz);
                internalTypeInfo.setQName(typeQName);
                internalTypeInfo.setSerializerClass(serializerFactoryClass);
                internalTypeInfo.setDeserializerClass(deserializerFactoryClass);
                populateInternalTypeInfo(clazz, typeQName, key, internalTypeInfo);
                typeInfoList.add(internalTypeInfo.buildTypeInfo());
            }
        }
        return typeInfoList;
    }

    private void populateInternalTypeInfo(Class javaClass, QName typeQName, SchemaTypeKey key, TypeInfo.UpdatableTypeInfo typeInfo) throws DeploymentException {
        SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
        if (schemaType == null) {
            throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
        }
        typeInfo.setCanSearchParents(schemaType.getDerivationType() == SchemaType.DT_RESTRICTION);
        Map nameToTy

        if (null == schemaType.getContentModel()) {
        } else if (SchemaParticle.SEQUENCE == schemaType.getContentModel().getParticleType() || SchemaParticle.ALL == schemaType.getContentModel().getParticleType()) {
            SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
            for (int i = 0; i < properties.length; i++) {
                SchemaParticle parameter = properties[i];
                // throw new DeploymentException(parameter.getName() + " is not an element in schema " + schemaType.getName());
                nameToType.put(parameter.getName(), parameter);
            }
        } else if (SchemaParticle.ELEMENT == schemaType.getContentModel().getParticleType()) {
            SchemaParticle parameter = schemaType.getContentModel();
            nameToType.put(parameter.getName(), parameter);
        } else {
            throw new DeploymentException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
        }
        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
        } catch (IntrospectionException e) {
            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
        }
        Map nameToClass = new HashMap();
        for (int i = 0; i < descriptors.length; i++) {
            nameToClass.put(descriptors[i].getName(), descriptors[i].getPropertyType());
        }
        int idx = 0;
        FieldDesc[] fields = new FieldDesc[nameToType.size()];
        typeInfo.setFields(fields);
        for (Iterator iter = nameToType.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iter.next();
            QName fieldQName = (QName) entry.getKey();
            String fieldName = fieldQName.getLocalPart();
            SchemaParticle particle = (SchemaParticle) entry.getValue();
            ElementDesc elementDesc = new ElementDesc();
            elementDesc.setFieldName(fieldName);
            Class javaType = (Class) nameToClass.get(fieldName);
            if (null == javaType) {
                throw new DeploymentException("Field " + fieldName + " is not defined by class " + javaClass.getName());
            }
            elementDesc.setNillable(particle.isNillable());
            elementDesc.setXmlName(fieldQName);
            elementDesc.setXmlType(particle.getType().getName());
            if (javaType.isArray()) {
                elementDesc.setMinOccurs(particle.getIntMinOccurs());
                elementDesc.setMaxOccurs(particle.getIntMaxOccurs());
                // TODO axis seems to have the wrong name for this property based on how it is used
                elementDesc.setMaxOccursUnbounded(particle.getIntMaxOccurs() > 1);
            }
            fields[idx++] = elementDesc;
        }
    }
}


for (int i = 0; i < properties.length; i++) {
                SchemaParticle parameter = properties[i];
                // throw new DeploymentException(parameter.getName() + " is not an element in schema " + schemaType.getName());
                nameToType.put(parameter.getName(), parameter);
            }

package org.apache.geronimo.axis.builder;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
import org.apache.axis.description.ElementDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.geronimo.axis.client.TypeInfo;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.webservices.builder.SchemaTypeKey;
import org.apache.geronimo.webservices.builder.WSDescriptorParser;
import org.apache.openejb.jee.JavaWsdlMapping;
import org.apache.xmlbeans.SchemaParticle;
import org.apache.xmlbeans.SchemaType;
import org.osgi.framework.Bundle;

public class LightweightTypeInfoBuilder implements TypeInfoBuilder {

    private final Bundle cl;

    private final Map schemaTypeKeyToSchemaTypeMap;

    private final Set wrapperElementQNames;

    public LightweightTypeInfoBuilder(Bundle bundle, Map schemaTypeKeyToSchemaTypeMap, Set wrapperElementQNames) {
        this.cl = bundle;
        this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
        this.wrapperElementQNames = wrapperElementQNames;
    }

    public List buildTypeInfo(JavaWsdlMapping mapping) throws DeploymentException {
        List typeInfoList = new ArrayList();
        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iterator.hasNext(); ) {
            SchemaTypeKey key = (SchemaTypeKey) iterator.next();
            if (!key.isElement() && !key.isAnonymous()) {
                QName typeQName = key.getqName();
                String namespace = typeQName.getNamespaceURI();
                String packageName = WSDescriptorParser.getPackageFromNamespace(namespace, mapping);
                String classShortName = typeQName.getLocalPart();
                String className = packageName + "." + classShortName;
                Class clazz = null;
                try {
                    clazz = ClassLoading.loadClass(className, cl);
                } catch (ClassNotFoundException e) {
                    throw new DeploymentException("Could not load java type", e);
                }
                Class serializerFactoryClass = BeanSerializerFactory.class;
                Class deserializerFactoryClass = BeanDeserializerFactory.class;
                if (clazz.isArray()) {
                    serializerFactoryClass = ArraySerializerFactory.class;
                    deserializerFactoryClass = ArrayDeserializerFactory.class;
                }
                TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
                internalTypeInfo.setClazz(clazz);
                internalTypeInfo.setQName(typeQName);
                internalTypeInfo.setSerializerClass(serializerFactoryClass);
                internalTypeInfo.setDeserializerClass(deserializerFactoryClass);
                populateInternalTypeInfo(clazz, typeQName, key, internalTypeInfo);
                typeInfoList.add(internalTypeInfo.buildTypeInfo());
            }
        }
        return typeInfoList;
    }

    private void populateInternalTypeInfo(Class javaClass, QName typeQName, SchemaTypeKey key, TypeInfo.UpdatableTypeInfo typeInfo) throws DeploymentException {
        SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
        if (schemaType == null) {
            throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
        }
        typeInfo.setCanSearchParents(schemaType.getDerivationType() == SchemaType.DT_RESTRICTION);
        Map nameToType = new HashMap();
        if (null == schemaType.getContentModel()) {
        } else if (SchemaParticle.SEQUENCE == schemaType.getContentModel().getParticleType() || SchemaParticle.ALL == schemaType.getContentModel().getParticleType()) {
            SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();

        } else if (SchemaParticle.ELEMENT == schemaType.getContentModel().getParticleType()) {
            SchemaParticle parameter = schemaType.getContentModel();
            nameToType.put(parameter.getName(), parameter);
        } else {
            throw new DeploymentException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
        }
        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
        } catch (IntrospectionException e) {
            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
        }
        Map nameToClass = new HashMap();
        for (int i = 0; i < descriptors.length; i++) {
            nameToClass.put(descriptors[i].getName(), descriptors[i].getPropertyType());
        }
        int idx = 0;
        FieldDesc[] fields = new FieldDesc[nameToType.size()];
        typeInfo.setFields(fields);
        for (Iterator iter = nameToType.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iter.next();
            QName fieldQName = (QName) entry.getKey();
            String fieldName = fieldQName.getLocalPart();
            SchemaParticle particle = (SchemaParticle) entry.getValue();
            ElementDesc elementDesc = new ElementDesc();
            elementDesc.setFieldName(fieldName);
            Class javaType = (Class) nameToClass.get(fieldName);
            if (null == javaType) {
                throw new DeploymentException("Field " + fieldName + " is not defined by class " + javaClass.getName());
            }
            elementDesc.setNillable(particle.isNillable());
            elementDesc.setXmlName(fieldQName);
            elementDesc.setXmlType(particle.getType().getName());
            if (javaType.isArray()) {
                elementDesc.setMinOccurs(particle.getIntMinOccurs());
                elementDesc.setMaxOccurs(particle.getIntMaxOccurs());
                // TODO axis seems to have the wrong name for this property based on how it is used
                elementDesc.setMaxOccursUnbounded(particle.getIntMaxOccurs() > 1);
            }
            fields[idx++] = elementDesc;
        }
    }
}


try {
                    clazz = ClassLoading.loadClass(className, cl);
                } catch (ClassNotFoundException e) {
                    throw new DeploymentException("Could not load java type", e);
                }

package org.apache.geronimo.axis.builder;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
import org.apache.axis.description.ElementDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.geronimo.axis.client.TypeInfo;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.webservices.builder.SchemaTypeKey;
import org.apache.geronimo.webservices.builder.WSDescriptorParser;
import org.apache.openejb.jee.JavaWsdlMapping;
import org.apache.xmlbeans.SchemaParticle;
import org.apache.xmlbeans.SchemaType;
import org.osgi.framework.Bundle;

public class LightweightTypeInfoBuilder implements TypeInfoBuilder {

    private final Bundle cl;

    private final Map schemaTypeKeyToSchemaTypeMap;

    private final Set wrapperElementQNames;

    public LightweightTypeInfoBuilder(Bundle bundle, Map schemaTypeKeyToSchemaTypeMap, Set wrapperElementQNames) {
        this.cl = bundle;
        this.schemaTypeKeyToSchemaTypeMap = schemaTypeKeyToSchemaTypeMap;
        this.wrapperElementQNames = wrapperElementQNames;
    }

    public List buildTypeInfo(JavaWsdlMapping mapping) throws DeploymentException {
        List typeInfoList = new ArrayList();
        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.keySet().iterator(); iterator.hasNext(); ) {
            SchemaTypeKey key = (SchemaTypeKey) iterator.next();
            if (!key.isElement() && !key.isAnonymous()) {
                QName typeQName = key.getqName();
                String namespace = typeQName.getNamespaceURI();
                String packageName = WSDescriptorParser.getPackageFromNamespace(namespace, mapping);
                String classShortName = typeQName.getLocalPart();
                String className = packageName + "." + classShortName;
                Class clazz = null;

                Class serializerFactoryClass = BeanSerializerFactory.class;
                Class deserializerFactoryClass = BeanDeserializerFactory.class;
                if (clazz.isArray()) {
                    serializerFactoryClass = ArraySerializerFactory.class;
                    deserializerFactoryClass = ArrayDeserializerFactory.class;
                }
                TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
                internalTypeInfo.setClazz(clazz);
                internalTypeInfo.setQName(typeQName);
                internalTypeInfo.setSerializerClass(serializerFactoryClass);
                internalTypeInfo.setDeserializerClass(deserializerFactoryClass);
                populateInternalTypeInfo(clazz, typeQName, key, internalTypeInfo);
                typeInfoList.add(internalTypeInfo.buildTypeInfo());
            }
        }
        return typeInfoList;
    }

    private void populateInternalTypeInfo(Class javaClass, QName typeQName, SchemaTypeKey key, TypeInfo.UpdatableTypeInfo typeInfo) throws DeploymentException {
        SchemaType schemaType = (SchemaType) schemaTypeKeyToSchemaTypeMap.get(key);
        if (schemaType == null) {
            throw new DeploymentException("Schema type key " + key + " not found in analyzed schema: " + schemaTypeKeyToSchemaTypeMap);
        }
        typeInfo.setCanSearchParents(schemaType.getDerivationType() == SchemaType.DT_RESTRICTION);
        Map nameToType = new HashMap();
        if (null == schemaType.getContentModel()) {
        } else if (SchemaParticle.SEQUENCE == schemaType.getContentModel().getParticleType() || SchemaParticle.ALL == schemaType.getContentModel().getParticleType()) {
            SchemaParticle[] properties = schemaType.getContentModel().getParticleChildren();
            for (int i = 0; i < properties.length; i++) {
                SchemaParticle parameter = properties[i];
                // throw new DeploymentException(parameter.getName() + " is not an element in schema " + schemaType.getName());
                nameToType.put(parameter.getName(), parameter);
            }
        } else if (SchemaParticle.ELEMENT == schemaType.getContentModel().getParticleType()) {
            SchemaParticle parameter = schemaType.getContentModel();
            nameToType.put(parameter.getName(), parameter);
        } else {
            throw new DeploymentException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
        }
        PropertyDescriptor[] descriptors;
        try {
            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
        } catch (IntrospectionException e) {
            throw new DeploymentException("Class " + javaClass + " is not a valid javabean", e);
        }
        Map nameToClass = new HashMap();
        for (int i = 0; i < descriptors.length; i++) {
            nameToClass.put(descriptors[i].getName(), descriptors[i].getPropertyType());
        }
        int idx = 0;
        FieldDesc[] fields = new FieldDesc[nameToType.size()];
        typeInfo.setFields(fields);
        for (Iterator iter = nameToType.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iter.next();
            QName fieldQName = (QName) entry.getKey();
            String fieldName = fieldQName.getLocalPart();
            SchemaParticle particle = (SchemaParticle) entry.getValue();
            ElementDesc elementDesc = new ElementDesc();
            elementDesc.setFieldName(fieldName);
            Class javaType = (Class) nameToClass.get(fieldName);
            if (null == javaType) {
                throw new DeploymentException("Field " + fieldName + " is not defined by class " + javaClass.getName());
            }
            elementDesc.setNillable(particle.isNillable());
            elementDesc.setXmlName(fieldQName);
            elementDesc.setXmlType(particle.getType().getName());
            if (javaType.isArray()) {
                elementDesc.setMinOccurs(particle.getIntMinOccurs());
                elementDesc.setMaxOccurs(particle.getIntMaxOccurs());
                // TODO axis seems to have the wrong name for this property based on how it is used
                elementDesc.setMaxOccursUnbounded(particle.getIntMaxOccurs() > 1);
            }
            fields[idx++] = elementDesc;
        }
    }
}


public static Expr[] concat(final Expr[] source, final Expr... add)

package org.basex.query.util.list;

import org.basex.query.expr.*;
import org.basex.util.*;
import org.basex.util.list.*;

/**
 * Resizable-array implementation for XQuery expressions.
 *
 * @author Christian Gruen
 */
public final class ExprList extends ObjectList<Expr, ExprList> {

    public ExprList() {
        this(1);
    }

    /**
     * Constructor with initial capacity.
     * @param capacity array capacity
     */
    public ExprList(final long capacity) {
        super(new Expr[Array.checkCapacity(capacity)]);
    }

    /**
     * Constructor, specifying an initial entry.
     * @param element array capacity
     */
    public ExprList(final Expr element) {
        super(element);
        size = 1;
    }

    /**
     * Concatenates entries.
     * @param source source elements
     * @param add elements to be added
     * @return array
     */

{
        final int sl = source.length, al = add.length;
        final Expr[] tmp = new Expr[sl + al];
        Array.copy(source, sl, tmp);
        Array.copyFromStart(add, al, tmp, sl);
        return tmp;
    }

    @Override
    protected Expr[] newArray(final int s) {
        return new Expr[s];
    }
}


{
        final int sl = source.length, al = add.length;
        final Expr[] tmp = new Expr[sl + al];
        Array.copy(source, sl, tmp);
        Array.copyFromStart(add, al, tmp, sl);
        return tmp;
    }

package org.basex.query.util.list;

import org.basex.query.expr.*;
import org.basex.util.*;
import org.basex.util.list.*;

/**
 * Resizable-array implementation for XQuery expressions.
 *
 * @author Christian Gruen
 */
public final class ExprList extends ObjectList<Expr, ExprList> {

    public ExprList() {
        this(1);
    }

    /**
     * Constructor with initial capacity.
     * @param capacity array capacity
     */
    public ExprList(final long capacity) {
        super(new Expr[Array.checkCapacity(capacity)]);
    }

    /**
     * Constructor, specifying an initial entry.
     * @param element array capacity
     */
    public ExprList(final Expr element) {
        super(element);
        size = 1;
    }

    /**
     * Concatenates entries.
     * @param source source elements
     * @param add elements to be added
     * @return array
     */
    public static Expr[] concat(final Expr[] source, final Expr... add)

    @Override
    protected Expr[] newArray(final int s) {
        return new Expr[s];
    }
}


package org.basex.query.util.list;

import org.basex.query.expr.*;
import org.basex.util.*;
import org.basex.util.list.*;

/**
 * Resizable-array implementation for XQuery expressions.
 *
 * @author Christian Gruen
 */
public final class ExprList extends ObjectList<Expr, ExprList> {

    public ExprList() {
        this(1);
    }

    /**
     * Constructor with initial capacity.
     * @param capacity array capacity
     */
    public ExprList(final long capacity) {
        super(new Expr[Array.checkCapacity(capacity)]);
    }

    /**
     * Constructor, specifying an initial entry.
     * @param element array capacity
     */
    public ExprList(final Expr element) {
        super(element);
        size = 1;
    }

    /**
     * Concatenates entries.
     * @param source source elements
     * @param add elements to be added
     * @return array
     */
    public static Expr[] concat(final Expr[] source, final Expr... add) {
        final int sl = source.length, al = add.length;
        final Expr[] tmp = new Expr[sl + al];
        Array.copy(source, sl, tmp);
        Array.copyFromStart(add, al, tmp, sl);
        return tmp;
    }

    @Override
    protected Expr[] newArray(final int s) {
        retur


public static Expr[] concat(final Expr[] source, final Expr... add) {
        final int sl = source.length, al = add.length;
        final Expr[] tmp = new Expr[sl + al];
        Array.copy(source, sl, tmp);
        Array.copyFromStart(add, al, tmp, sl);
        return tmp;
    }


package org.csstudio.utility.eliza;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Standalone SWT Test of ElizaGUI
 *  @author Kay Kasemir
 */
public class TestMain {

{
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setBounds(400, 100, 300, 350);
        new ElizaGUI(shell);
        shell.open();
        // Message loop left to the application
        while (!shell.isDisposed()) if (!display.readAndDispatch())
            display.sleep();
        display.dispose();
    }
}


{
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setBounds(400, 100, 300, 350);
        new ElizaGUI(shell);
        shell.open();
        // Message loop left to the application
        while (!shell.isDisposed()) if (!display.readAndDispatch())
            display.sleep();
        display.dispose();
    }

package org.csstudio.utility.eliza;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Standalone SWT Test of ElizaGUI
 *  @author Kay Kasemir
 */
public class TestMain {

    public static void main(String[] args)


package org.csstudio.utility.eliza;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Standalone SWT Test of ElizaGUI
 *  @author Kay Kasemir
 */
public class TestMain {

    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setBounds(400, 100, 300, 350);
        new ElizaGUI(shell);
        shell.open

        // Message loop left to the application
        while (!shell.isDisposed()) if (!display.readAndDispatch())
            display.sleep();
        display.dispose();
    }
}


while (!shell.isDisposed()) if (!display.readAndDispatch())
            display.sleep();

package org.csstudio.utility.eliza;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Standalone SWT Test of ElizaGUI
 *  @author Kay Kasemir
 */
public class TestMain {

    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setBounds(400, 100, 300, 350);
        new ElizaGUI(shell);
        shell.open();
        // Message loop left to the application


@Override
    protected String getOrCreateServiceUser(HttpServletRequest request, String accessToken) throws IOException

package org.nuxeo.ecm.platform.oauth2.providers;

import org.nuxeo.ecm.platform.oauth2.tokens.NuxeoOAuth2Token;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * {@link org.nuxeo.ecm.platform.oauth2.providers.OAuth2ServiceProvider} that relies on the user's email as key.
 *
 * @since 7.3
 */
public abstract class AbstractOAuth2UserEmailProvider extends NuxeoOAuth2ServiceProvider {

{
        String email = getUserEmail(accessToken);
        String userId = getServiceUserId(email);
        if (userId == null) {
            String nuxeoLogin = request.getUserPrincipal().getName();
            Map<String, Object> fields = new HashMap<>();
            fields.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
            userId = getServiceUserStore().store(nuxeoLogin, fields);
        }
        return userId;
    }

    @Override
    protected String getServiceUserId(String email) {
        Map<String, Serializable> filter = new HashMap<>();
        filter.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
        return getServiceUserStore().find(filter);
    }

    protected abstract String getUserEmail(String accessToken) throws IOException;
}


{
        Map<String, Serializable> filter = new HashMap<>();
        filter.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
        return getServiceUserStore().find(filter);
    }

package org.nuxeo.ecm.platform.oauth2.providers;

import org.nuxeo.ecm.platform.oauth2.tokens.NuxeoOAuth2Token;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * {@link org.nuxeo.ecm.platform.oauth2.providers.OAuth2ServiceProvider} that relies on the user's email as key.
 *
 * @since 7.3
 */
public abstract class AbstractOAuth2UserEmailProvider extends NuxeoOAuth2ServiceProvider {

    @Override
    protected String getOrCreateServiceUser(HttpServletRequest request, String accessToken) throws IOException {
        String email = getUserEmail(accessToken);
        String userId = getServiceUserId(email);
        if (userId == null) {
            String nuxeoLogin = request.getUserPrincipal().getName();
            Map<String, Object> fields = new HashMap<>();
            fields.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
            userId = getServiceUserStore().store(nuxeoLogin, fields);
        }
        return userId;
    }

    @Override
    protected String getServiceUserId(String email)

    protected abstract String getUserEmail(String accessToken) throws IOException;
}


package org.nuxeo.ecm.platform.oauth2.providers;

import org.nuxeo.ecm.platform.oauth2.tokens.NuxeoOAuth2Token;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * {@link org.nuxeo.ecm.platform.oauth2.providers.OAuth2ServiceProvider} that relies on the user's email as key.
 *
 * @since 7.3
 */
public abstract class AbstractOAuth2UserEmailProvider extends NuxeoOAuth2ServiceProvider {

    @Override
    protected String getOrCreateServiceUser(HttpServletRequest request, String accessToken) throws IOException {
        String email = getUserEmail(accessT

        String userId = getServiceUserId(email);
        if (userId == null) {
            String nuxeoLogin = request.getUserPrincipal().getName();
            Map<String, Object> fields = new HashMap<>();
            fields.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
            userId = getServiceUserStore().store(nuxeoLogin, fields);
        }
        return userId;
    }

    @Override
    protected String getServiceUserId(String email) {
        Map<String, Serializable> filter = new HashMap<>();
        filter.put(NuxeoOAuth2Token.KEY_SERVICE_LOGIN, email);
        return getServiceUserStore().find(filter);
    }

    protected abstract String getUserEmail(String accessToken) throws IOException;
}


public void setValidationState(ValidationState validationState)

package com.sequenceiq.mock.swagger.model;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.sequenceiq.mock.swagger.model.ValidationState;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;

/**
 * Model for a configuration parameter.  When an entry's <i>value</i> property is not available, it means the entry is not configured. This means that the default value for the entry, if any, will be used. Setting a value to <i>null</i> also can be used to unset any previously set value for the parameter, reverting to the default value (if any).
 */
@ApiModel(description = "Model for a configuration parameter.  When an entry's value property is not available, it means the entry is not configured. This means that the default value for the entry, if any, will be used. Setting a value to null also can be used to unset any previously set value for the parameter, reverting to the default value (if any).")
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-10-26T08:01:08.932+01:00")
public class ApiConfig {

    @JsonProperty("name")
    private String name = null;

    @JsonProperty("value")
    private String value = null;

    @JsonProperty("required")
    private Boolean required = null;

    @JsonProperty("default")
    private String _default = null;

    @JsonProperty("displayName")
    private String displayName = null;

    @JsonProperty("description")
    private String description = null;

    @JsonProperty("relatedName")
    private String relatedName = null;

    @JsonProperty("sensitive")
    private Boolean sensitive = null;

    @JsonProperty("validationState")
    private ValidationState validationState = null;

    @JsonProperty("validationMessage")
    private String validationMessage = null;

    @JsonProperty("validationWarningsSuppressed")
    private Boolean validationWarningsSuppressed = null;

    public ApiConfig name(String name) {
        this.name = name;
        return this;
    }

    /**
     * Readonly. The canonical name that identifies this configuration parameter.
     * @return name
     */
    @ApiModelProperty(value = "Readonly. The canonical name that identifies this configuration parameter.")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ApiConfig value(String value) {
        this.value = value;
        return this;
    }

    /**
     * The user-defined value. When absent, the default value (if any) will be used. Can also be absent, when enumerating allowed configs.
     * @return value
     */
    @ApiModelProperty(value = "The user-defined value. When absent, the default value (if any) will be used. Can also be absent, when enumerating allowed configs.")
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public ApiConfig required(Boolean required) {
        this.required = required;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. Whether this configuration is required for the object. If any required configuration is not set, operations on the object may not work.
     * @return required
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. Whether this configuration is required for the object. If any required configuration is not set, operations on the object may not work.")
    public Boolean isRequired() {
        return required;
    }

    public void setRequired(Boolean required) {
        this.required = required;
    }

    public ApiConfig _default(String _default) {
        this._default = _default;
        return this;
    }

    @ApiModelProperty(value = "Readonly. Requires \"full\" view. The default value.")
    public String getDefault() {
        return _default;
    }

    public void setDefault(String _default) {
        this._default = _default;
    }

    public ApiConfig displayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. A user-friendly name of the parameters, as would have been shown in the web UI.
     * @return displayName
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. A user-friendly name of the parameters, as would have been shown in the web UI.")
    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public ApiConfig description(String description) {
        this.description = description;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. A textual description of the parameter.
     * @return description
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. A textual description of the parameter.")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public ApiConfig relatedName(String relatedName) {
        this.relatedName = relatedName;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. If applicable, contains the related configuration variable used by the source project.
     * @return relatedName
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. If applicable, contains the related configuration variable used by the source project.")
    public String getRelatedName() {
        return relatedName;
    }

    public void setRelatedName(String relatedName) {
        this.relatedName = relatedName;
    }

    public ApiConfig sensitive(Boolean sensitive) {
        this.sensitive = sensitive;
        return this;
    }

    /**
     * Readonly. Whether this configuration is sensitive, i.e. contains information such as passwords, which might affect how the value of this configuration might be shared by the caller.  Available since v14.
     * @return sensitive
     */
    @ApiModelProperty(value = "Readonly. Whether this configuration is sensitive, i.e. contains information such as passwords, which might affect how the value of this configuration might be shared by the caller.  Available since v14.")
    public Boolean isSensitive() {
        return sensitive;
    }

    public void setSensitive(Boolean sensitive) {
        this.sensitive = sensitive;
    }

    public ApiConfig validationState(ValidationState validationState) {
        this.validationState = validationState;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. State of the configuration parameter after validation.
     * @return validationState
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. State of the configuration parameter after validation.")
    @Valid
    public ValidationState getValidationState() {
        return validationState;
    }

{
        this.validationState = validationState;
    }

    public ApiConfig validationMessage(String validationMessage) {
        this.validationMessage = validationMessage;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. A message explaining the parameter's validation state.
     * @return validationMessage
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. A message explaining the parameter's validation state.")
    public String getValidationMessage() {
        return validationMessage;
    }

    public void setValidationMessage(String validationMessage) {
        this.validationMessage = validationMessage;
    }

    public ApiConfig validationWarningsSuppressed(Boolean validationWarningsSuppressed) {
        this.validationWarningsSuppressed = validationWarningsSuppressed;
        return this;
    }

    /**
     * Readonly. Requires \"full\" view. Whether validation warnings associated with this parameter are suppressed. In general, suppressed validation warnings are hidden in the Cloudera Manager UI. Configurations that do not produce warnings will not contain this field.
     * @return validationWarningsSuppressed
     */
    @ApiModelProperty(value = "Readonly. Requires \"full\" view. Whether validation warnings associated with this parameter are suppressed. In general, suppressed validation warnings are hidden in the Cloudera Manager UI. Configurations that do not produce warnings will not contain this field.")
    public Boolean isValidationWarningsSuppressed() {
        return validationWarningsSuppressed;
    }

    public void setValidationWarningsSuppressed(Boolean validationWarningsSuppressed) {
        this.validationWarningsSuppressed = validationWarningsSuppressed;
    }

    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ApiConfig apiConfig = (ApiConfig) o;
        return Objects.equals(this.name, apiConfig.name) && Objects.equals(this.value, apiConfig.value) && Objects.equals(this.required, apiConfig.required) && Objects.equals(this._default, apiConfig._default) && Objects.equals(this.displayName, apiConfig.displayName) && Objects.equals(this.description, apiConfig.description) && Objects.equals(this.relatedName, apiConfig.relatedName) && Objects.equals(this.sensitive, apiConfig.sensitive) && Objects.equals(this.validationState, apiConfig.validationState) && Objects.equals(this.validationMessage, apiConfig.validationMessage) && Objects.equals(this.validationWarningsSuppressed, apiConfig.validationWarningsSuppressed);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, value, required, _default, displayName, description, relatedName, sensitive, validationState, validationMessage, validationWarningsSuppressed);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ApiConfig {\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    value: ").append(toIndentedString(value)).append("\n");
        sb.append("    required: ").append(toIndentedString(required)).append("\n");
        sb.append("    _default: ").append(toIndentedString(_default)).append("\n");
        sb.append("    displayName: ").append(toIndentedString(displayName)).append("\n");
        sb.append("    description: ").append(toIndentedString(description)).append("\n");
        sb.append("    relatedName: ").append(toIndentedString(relatedName)).append("\n");
        sb.append("    sensitive: ").append(toIndentedString(sensitive)).append("\n");
        sb.append("    validationState: ").append(toIndentedString(validationState)).append("\n");
        sb.append("    validationMessage: ").append(toIndentedString(validationMessage)).append("\n");
        sb.append("    validationWarningsSuppressed: ").append(toIndentedString(validationWarningsSuppressed)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(java.lang.Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}