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.LinkedHashMap;
023import java.util.LinkedHashSet;
024import java.util.LinkedList;
025import java.util.List;
026import java.util.Map;
027import java.util.Set;
028import java.util.function.Function;
029import lombok.EqualsAndHashCode;
030import lombok.Getter;
031import lombok.NoArgsConstructor;
032import lombok.Synchronized;
033
034import static lombok.AccessLevel.PROTECTED;
035
036/**
037 * Abstract base class for {@link.uri http://www.upnp.org/ UPnP}
038 * {@link Service}s.
039 *
040 * {@bean.info}
041 *
042 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball}
043 */
044@NoArgsConstructor(access = PROTECTED) @EqualsAndHashCode
045public abstract class AbstractService implements AnnotatedService {
046    @Getter
047    private final List<? extends Action> actionList = new LinkedList<>();
048    @Getter
049    private final List<? extends StateVariable> serviceStateTable = new LinkedList<>();
050    private Map<URI,Set<URI>> map = null;
051
052    @Synchronized
053    @Override
054    public Map<URI,Set<URI>> getUSNMap() {
055        if (map == null) {
056            map = AnnotatedService.super.getUSNMap();
057        }
058
059        return map;
060    }
061
062    @Override
063    public String toString() { return getServiceType().toString(); }
064}