/**
 * Copyright (C) 2009 - 2009 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.engine.security;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import org.fudgemsg.FudgeMsg;

import com.opengamma.engine.analytics.AnalyticValueDefinition;
import com.opengamma.id.DomainSpecificIdentifier;

/**
 * A concrete, JavaBean-based implementation of {@link Security}. 
 *
 * @author kirk
 */
public class DefaultSecurity implements Security, Serializable {
  private Collection<DomainSpecificIdentifier> _identifiers;
  private String _securityType;
  private AnalyticValueDefinition<FudgeMsg> _marketDataDefinition;
  
  public DefaultSecurity() {
  }
  
  public DefaultSecurity(String securityType, Collection<? extends DomainSpecificIdentifier> identifiers) {
    setSecurityType(securityType);
    setIdentifiers(identifiers);
  }

  @Override
  public Collection<DomainSpecificIdentifier> getIdentifiers() {
    return _identifiers;
  }

  /**
   * This will create a <em>copy</em> of the provided collection.
   * @param identifiers the identifiers to set
   */
  public void setIdentifiers(Collection<? extends DomainSpecificIdentifier> identifiers) {
    _identifiers = new ArrayList<DomainSpecificIdentifier>(identifiers);
  }
  
  // REVIEW jim 23-Sep-2009 -- maybe this should be separate from the identifiers
  // REVIEW kirk 2009-10-16 -- Almost certainly.
  @Override
  public SecurityKey getIdentityKey() {
    return new SecurityKeyImpl(_identifiers);
  }

  @Override
  public String getSecurityType() {
    return _securityType;
  }

  /**
   * @param securityType the securityType to set
   */
  public void setSecurityType(String securityType) {
    _securityType = securityType;
  }

  @Override
  public AnalyticValueDefinition<FudgeMsg> getMarketDataDefinition() {
    return _marketDataDefinition;
  }

  /**
   * @param marketDataDefinition the marketDataDefinition to set
   */
  public void setMarketDataDefinition(
      AnalyticValueDefinition<FudgeMsg> marketDataDefinition) {
    _marketDataDefinition = marketDataDefinition;
  }
}

@@ -164,36 +164,8 @@
 le;%0A
-import java.util.ArrayList;%0A
 impo
@@ -189,16 +189,16 @@
 ection;%0A
+
 %0Aimport 
@@ -333,16 +333,71 @@
 ntifier;
+%0Aimport com.opengamma.id.DomainSpecificIdentifiersImpl;
 %0A%0A/**%0A *
@@ -559,27 +559,16 @@
 private 
-Collection%3C
 DomainSp
@@ -583,17 +583,21 @@
 entifier
-%3E
+sImpl
  _identi
@@ -1018,24 +1018,41 @@
 _identifiers
+.getIdentifiers()
 ;%0A  %7D%0A%0A  /**
@@ -1289,18 +1289,8 @@
 new 
-ArrayList%3C
 Doma
@@ -1309,17 +1309,21 @@
 entifier
-%3E
+sImpl
 (identif
@@ -1515,24 +1515,24 @@
 tityKey() %7B%0A
-
     return n
@@ -1554,32 +1554,49 @@
 mpl(_identifiers
+.getIdentifiers()
 );%0A  %7D%0A%0A  @Overr

Use DomainSpecificIdentifiersImpl to manage identifiers