001package ball.upnp;
002/*-
003 * ##########################################################################
004 * UPnP/SSDP Implementation Classes
005 * $Id: AbstractService.java 7215 2021-01-03 18:39:51Z ball $
006 * $HeadURL: svn+ssh://svn.hcf.dev/var/spool/scm/repository.svn/ball-upnp/trunk/src/main/java/ball/upnp/AbstractService.java $
007 * %%
008 * Copyright (C) 2013 - 2021 Allen D. Ball
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the "License");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 *
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 *
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an "AS IS" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * ##########################################################################
022 */
023import java.net.URI;
024import java.util.LinkedHashMap;
025import java.util.LinkedHashSet;
026import java.util.LinkedList;
027import java.util.List;
028import java.util.Map;
029import java.util.Set;
030import java.util.function.Function;
031import lombok.EqualsAndHashCode;
032import lombok.Getter;
033import lombok.NoArgsConstructor;
034import lombok.Synchronized;
035
036import static lombok.AccessLevel.PROTECTED;
037
038/**
039 * Abstract base class for {@link.uri http://www.upnp.org/ UPnP}
040 * {@link Service}s.
041 *
042 * {@bean.info}
043 *
044 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball}
045 * @version $Revision: 7215 $
046 */
047@NoArgsConstructor(access = PROTECTED) @EqualsAndHashCode
048public abstract class AbstractService implements AnnotatedService {
049    @Getter
050    private final List<? extends Action> actionList = new LinkedList<>();
051    @Getter
052    private final List<? extends StateVariable> serviceStateTable =
053        new LinkedList<>();
054    private Map<URI,Set<URI>> map = null;
055
056    @Synchronized
057    @Override
058    public Map<URI,Set<URI>> getUSNMap() {
059        if (map == null) {
060            map = AnnotatedService.super.getUSNMap();
061        }
062
063        return map;
064    }
065
066    @Override
067    public String toString() { return getServiceType().toString(); }
068}