001/*
002 * JGrapes Event driven Framework
003 * Copyright (C) 2022 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.mail.events;
020
021import java.util.Arrays;
022
023/**
024 * An event that opens folders on the store defined by the
025 * base class for monitoring.
026 */
027public class OpenMailMonitor extends OpenMailConnection {
028
029    private String[] folderNames = { "INBOX" };
030
031    /**
032     * Creates a new monitor connection (see {@link OpenMailConnection}) 
033     * that sends events related to watching the specified folders.
034     *
035     * @param folderNames the folders, defaults to "INBOX"
036     */
037    public OpenMailMonitor(String... folderNames) {
038        if (folderNames.length > 0) {
039            this.folderNames = Arrays.copyOf(folderNames, folderNames.length);
040        }
041    }
042
043    /**
044     * Returns the watched folders.
045     *
046     * @return the string[]
047     */
048    @SuppressWarnings("PMD.MethodReturnsInternalArray")
049    public String[] folderNames() {
050        return folderNames;
051    }
052
053}