001/**
002 *
003 * Copyright 2019-2023 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smack.packet;
018
019import org.jivesoftware.smack.packet.IQ.Type;
020
021public interface IqView extends StanzaView {
022
023    /**
024     * Returns the type of the IQ packet.
025     *
026     * @return the type of the IQ packet.
027     */
028    IQ.Type getType();
029
030    /**
031     * Return true if this IQ is a request IQ, i.e. an IQ of type {@link Type#get} or {@link Type#set}.
032     *
033     * @return true if IQ type is 'get' or 'set', false otherwise.
034     * @since 4.1
035     */
036    default boolean isRequestIQ() {
037        IQ.Type type = getType();
038        return type == IQ.Type.get || type == IQ.Type.set;
039    }
040
041    /**
042     * Return true if this IQ is a request, i.e. an IQ of type {@link Type#result} or {@link Type#error}.
043     *
044     * @return true if IQ type is 'result' or 'error', false otherwise.
045     * @since 4.4
046     */
047    default boolean isResponseIQ() {
048        return !isRequestIQ();
049    }
050}