/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.aries.subsystem.modelling.impl;


import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.apache.aries.subsystem.modelling.ExportedService;
import org.apache.aries.subsystem.modelling.ImportedService;
import org.apache.aries.subsystem.modelling.ParsedServiceElements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * A simple data structure containing two immutable Collections, 
 * one each of ImportedServiceImpl and ExportedServiceImpl
 */
public final class ParsedServiceElementsImpl implements ParsedServiceElements
{
 
  private final Logger logger = LoggerFactory.getLogger(ParsedServiceElementsImpl.class);
  private final Set<ExportedService> _services;
  private final Set<ImportedService> _references;
  
  /**
   * Copy collections of Service and Reference metadata into a ParsedServiceElementsImpl
   * @param services
   * @param references
   */
  public ParsedServiceElementsImpl ( Collection<ExportedService> services, 
      Collection<ImportedService> references) { 
    logger.debug("Method entry: {}, args {}", "ParsedServiceElementsImpl", new Object[]{services, references});
    _services = new HashSet<ExportedService>(services);
    _references = new HashSet<ImportedService>(references);
    logger.debug("Method entry: {}, args {}", "ParsedServiceElementsImpl");
  }

  /**
   * Get the ImportedServices
   * @return imported services
   */
  public Collection<ImportedService> getReferences() {
    logger.debug("Method entry: {}, args {}", "getReferences");
    logger.debug("Method exit: {}, returning {}", "getReferences", _references);
    return Collections.unmodifiableCollection(_references);
  }

  /**
   * Get the exported services
   * @return exported services
   */
  public Collection<ExportedService> getServices() {
    logger.debug("Method entry: {}, args {}", "getServices");
    logger.debug("Method exit: {}, returning {}", "getServices", _services);
    return Collections.unmodifiableCollection(_services);
  }
}
