001package ball.upnp;
002/*-
003 * ##########################################################################
004 * UPnP/SSDP Implementation Classes
005 * %%
006 * Copyright (C) 2013 - 2022 Allen D. Ball
007 * %%
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *      http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 * ##########################################################################
020 */
021import java.net.URI;
022import java.util.Map;
023import java.util.Set;
024import java.util.function.BiConsumer;
025
026/**
027 * {@link.uri http://www.upnp.org/ UPnP} {@link RootDevice} interface.
028 *
029 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball}
030 */
031public interface RootDevice extends Device {
032
033    /**
034     * {@code upnp:rootdevice}
035     */
036    public static final URI NT = URI.create("upnp:rootdevice");
037
038    /**
039     * {@code CONFIGID.UPNP.ORG}
040     *
041     * @return  {@code configID}
042     */
043    default int getConfigId() { return 1; }
044
045    /**
046     * {@code CACHE-CONTROL: MAX-AGE}
047     *
048     * @return  {@code MAX-AGE}
049     */
050    default int getMaxAge() { return 1800; }
051
052    /**
053     * {@code LOCATION}
054     *
055     * @return  Description {@link URI}
056     */
057    public URI getLocation();
058
059    /**
060     * Method to get {@link.this} {@link RootDevice}'s presentation
061     * {@code URL} (as an {@link URI}).
062     *
063     * @return  The presentation {@link URI}.
064     */
065    public URI getPresentationURL();
066
067    /**
068     * Method to invoke {@link BiConsumer consumer} for every {@link URI NT}
069     * / {@link URI USN} combinations representing the {@link RootDevice}
070     * with embedded {@link Service}s and {@link Device}s.
071     *
072     * @param   consumer        The {@link BiConsumer}.
073     */
074    default void notify(BiConsumer<URI,URI> consumer) {
075        getUSNMap().forEach((usn, v) -> v.forEach(nt -> consumer.accept(nt, usn)));
076    }
077}