All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gnome.soup.SessionError Maven / Gradle / Ivy

The newest version!
// Java-GI - Java language bindings for GObject-Introspection-based libraries
// Copyright (C) 2022-2024 Jan-Willem Harmannij
//
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see .
//
// This file has been generated with Java-GI.
// Do not edit this file directly!
// Visit  for more information.
//
package org.gnome.soup;

import io.github.jwharm.javagi.base.Enumeration;
import io.github.jwharm.javagi.base.UnsupportedPlatformException;
import io.github.jwharm.javagi.interop.Interop;
import io.github.jwharm.javagi.interop.Platform;
import java.lang.IllegalStateException;
import java.lang.Override;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.ValueLayout;
import java.lang.invoke.MethodHandle;
import javax.annotation.processing.Generated;
import org.gnome.glib.Quark;
import org.gnome.glib.Type;

/**
 * A {@code SoupSession} error.
 */
@Generated("io.github.jwharm.JavaGI")
public enum SessionError implements Enumeration {
    /**
     * the server's response could not
     *   be parsed
     */
    PARSING(0),

    /**
     * the server's response was in an
     *   unsupported format
     */
    ENCODING(1),

    /**
     * the message has been redirected
     *   too many times
     */
    TOO_MANY_REDIRECTS(2),

    /**
     * the message has been restarted
     *   too many times
     */
    TOO_MANY_RESTARTS(3),

    /**
     * failed to redirect message because
     *   Location header was missing or empty in response
     */
    REDIRECT_NO_LOCATION(4),

    /**
     * failed to redirect message because
     *   Location header contains an invalid URI
     */
    REDIRECT_BAD_URI(5),

    /**
     * the message is already in the
     *   session queue. Messages can only be reused after unqueued.
     */
    MESSAGE_ALREADY_IN_QUEUE(6);

    static {
        Soup.javagi$ensureInitialized();
    }

    private final int value;

    /**
     * Create a new SessionError for the provided value
     *
     * @param value the enum value
     */
    private SessionError(int value) {
        this.value = value;
    }

    /**
     * Create a new SessionError for the provided value
     *
     * @param value the enum value
     * @return the enum for the provided value
     */
    public static SessionError of(int value) {
        return switch(value) {
            case 0 -> PARSING;
            case 1 -> ENCODING;
            case 2 -> TOO_MANY_REDIRECTS;
            case 3 -> TOO_MANY_RESTARTS;
            case 4 -> REDIRECT_NO_LOCATION;
            case 5 -> REDIRECT_BAD_URI;
            case 6 -> MESSAGE_ALREADY_IN_QUEUE;
            default -> throw new IllegalStateException("Unexpected value: " + value);
        } ;
    }

    /**
     * Get the numeric value of this enum
     *
     * @return the enum value
     */
    @Override
    public int getValue() {
        return value;
    }

    /**
     * Get the GType of the SessionError class
     *
     * @return the GType
     */
    public static Type getType() {
        return Interop.getType("soup_session_error_get_type");
    }

    /**
     * Registers error quark for SoupSession if needed.
     * @return Error quark for SoupSession.
     * @throws UnsupportedPlatformException when run on a platform other than linux
     */
    public static Quark quark() throws UnsupportedPlatformException {
        Platform.checkSupportedPlatform("linux");
        int _result;
        try {
            _result = (int) MethodHandles.soup_session_error_quark.invokeExact();
        } catch (Throwable _err) {
            throw new AssertionError(_err);
        }
        return new Quark(_result);
    }

    private static final class MethodHandles {
        static final MethodHandle soup_session_error_quark = Interop.downcallHandle(
                "soup_session_error_quark", FunctionDescriptor.of(ValueLayout.JAVA_INT), false);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy