001/**
002 *
003 * Copyright 2017 Paul Schaub
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.smackx.omemo.exceptions;
018
019import java.util.HashSet;
020
021import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
022
023/**
024 * Exception that is thrown when the user tries to encrypt a message for a undecided device.
025 *
026 * @author Paul Schaub
027 */
028public class UndecidedOmemoIdentityException extends Exception {
029    private static final long serialVersionUID = -6591706422506879747L;
030    private final HashSet<OmemoDevice> devices = new HashSet<>();
031
032    public UndecidedOmemoIdentityException(OmemoDevice contact) {
033        super();
034        this.devices.add(contact);
035    }
036
037    /**
038     * Return the HashSet of undecided devices.
039     *
040     * @return undecided devices
041     */
042    public HashSet<OmemoDevice> getUndecidedDevices() {
043        return this.devices;
044    }
045
046    /**
047     * Add all undecided devices of another Exception to this Exceptions HashSet of undecided devices.
048     *
049     * @param other other Exception
050     */
051    public void join(UndecidedOmemoIdentityException other) {
052        this.devices.addAll(other.getUndecidedDevices());
053    }
054}