<commit_before>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.examples.bloomberg.component;

import java.util.LinkedHashMap;
import java.util.Map;

import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

import com.opengamma.component.ComponentInfo;
import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.AbstractComponentFactory;
import com.opengamma.financial.security.DefaultSecurityLoader;
import com.opengamma.master.security.SecurityLoader;
import com.opengamma.master.security.SecurityMaster;
import com.opengamma.provider.security.SecurityProvider;
import org.joda.beans.Bean;

/**
 * Component factory that instantiates the security loader.
 */
@BeanDefinition
public class ExampleSecurityLoaderComponentFactory extends AbstractComponentFactory {

  /**
   * The configuration URI.
   */
  @PropertyDefinition(validate = "notNull")
  private String _classifier;

  /**
   * The security provider.
   */
  @PropertyDefinition(validate = "notNull")
  private SecurityProvider _securityProvider;
  /**
   * The security master.
   */
  @PropertyDefinition
  private SecurityMaster _securityMaster;

  //-------------------------------------------------------------------------
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
    SecurityLoader securityLoader = new DefaultSecurityLoader(getSecurityMaster(), getSecurityProvider());
    
    ComponentInfo info = new ComponentInfo(SecurityLoader.class, getClassifier());
    repo.registerComponent(info, securityLoader);
  }

  //------------------------- AUTOGENERATED START -------------------------
  ///CLOVER:OFF
  /**
   * The meta-bean for {@code ExampleSecurityLoaderComponentFactory}.
   * @return the meta-bean, not null
   */
  public static ExampleSecurityLoaderComponentFactory.Meta meta() {
    return ExampleSecurityLoaderComponentFactory.Meta.INSTANCE;
  }

  static {
    JodaBeanUtils.registerMetaBean(ExampleSecurityLoaderComponentFactory.Meta.INSTANCE);
  }

  @Override
  public ExampleSecurityLoaderComponentFactory.Meta metaBean() {
    return ExampleSecurityLoaderComponentFactory.Meta.INSTANCE;
  }

  //-----------------------------------------------------------------------
  /**
   * Gets the configuration URI.
   * @return the value of the property, not null
   */
  public String getClassifier() {
    return _classifier;
  }

  /**
   * Sets the configuration URI.
   * @param classifier  the new value of the property, not null
   */
  public void setClassifier(String classifier) {
    JodaBeanUtils.notNull(classifier, "classifier");
    this._classifier = classifier;
  }

  /**
   * Gets the the {@code classifier} property.
   * @return the property, not null
   */
  public final Property<String> classifier() {
    return metaBean().classifier().createProperty(this);
  }

  //-----------------------------------------------------------------------
  /**
   * Gets the security provider.
   * @return the value of the property, not null
   */
  public SecurityProvider getSecurityProvider() {
    return _securityProvider;
  }

  /**
   * Sets the security provider.
   * @param securityProvider  the new value of the property, not null
   */
  public void setSecurityProvider(SecurityProvider securityProvider) {
    JodaBeanUtils.notNull(securityProvider, "securityProvider");
    this._securityProvider = securityProvider;
  }

  /**
   * Gets the the {@code securityProvider} property.
   * @return the property, not null
   */
  public final Property<SecurityProvider> securityProvider() {
    return metaBean().securityProvider().createProperty(this);
  }

  //-----------------------------------------------------------------------
  /**
   * Gets the security master.
   * @return the value of the property
   */
  public SecurityMaster getSecurityMaster() {
    return _securityMaster;
  }

  /**
   * Sets the security master.
   * @param securityMaster  the new value of the property
   */
  public void setSecurityMaster(SecurityMaster securityMaster) {
    this._securityMaster = securityMaster;
  }

  /**
   * Gets the the {@code securityMaster} property.
   * @return the property, not null
   */
  public final Property<SecurityMaster> securityMaster() {
    return metaBean().securityMaster().createProperty(this);
  }

  //-----------------------------------------------------------------------
  @Override
  public ExampleSecurityLoaderComponentFactory clone() {
    return (ExampleSecurityLoaderComponentFactory) super.clone();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
      ExampleSecurityLoaderComponentFactory other = (ExampleSecurityLoaderComponentFactory) obj;
      return JodaBeanUtils.equal(getClassifier(), other.getClassifier()) &&
          JodaBeanUtils.equal(getSecurityProvider(), other.getSecurityProvider()) &&
          JodaBeanUtils.equal(getSecurityMaster(), other.getSecurityMaster()) &&
          super.equals(obj);
    }
    return false;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash += hash * 31 + JodaBeanUtils.hashCode(getClassifier());
    hash += hash * 31 + JodaBeanUtils.hashCode(getSecurityProvider());
    hash += hash * 31 + JodaBeanUtils.hashCode(getSecurityMaster());
    return hash ^ super.hashCode();
  }

  @Override
  public String toString() {
    StringBuilder buf = new StringBuilder(128);
    buf.append("ExampleSecurityLoaderComponentFactory{");
    int len = buf.length();
    toString(buf);
    if (buf.length() > len) {
      buf.setLength(buf.length() - 2);
    }
    buf.append('}');
    return buf.toString();
  }

  @Override
  protected void toString(StringBuilder buf) {
    super.toString(buf);
    buf.append("classifier").append('=').append(JodaBeanUtils.toString(getClassifier())).append(',').append(' ');
    buf.append("securityProvider").append('=').append(JodaBeanUtils.toString(getSecurityProvider())).append(',').append(' ');
    buf.append("securityMaster").append('=').append(JodaBeanUtils.toString(getSecurityMaster())).append(',').append(' ');
  }

  //-----------------------------------------------------------------------
  /**
   * The meta-bean for {@code ExampleSecurityLoaderComponentFactory}.
   */
  public static class Meta extends AbstractComponentFactory.Meta {
    /**
     * The singleton instance of the meta-bean.
     */
    static final Meta INSTANCE = new Meta();

    /**
     * The meta-property for the {@code classifier} property.
     */
    private final MetaProperty<String> _classifier = DirectMetaProperty.ofReadWrite(
        this, "classifier", ExampleSecurityLoaderComponentFactory.class, String.class);
    /**
     * The meta-property for the {@code securityProvider} property.
     */
    private final MetaProperty<SecurityProvider> _securityProvider = DirectMetaProperty.ofReadWrite(
        this, "securityProvider", ExampleSecurityLoaderComponentFactory.class, SecurityProvider.class);
    /**
     * The meta-property for the {@code securityMaster} property.
     */
    private final MetaProperty<SecurityMaster> _securityMaster = DirectMetaProperty.ofReadWrite(
        this, "securityMaster", ExampleSecurityLoaderComponentFactory.class, SecurityMaster.class);
    /**
     * The meta-properties.
     */
    private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
        this, (DirectMetaPropertyMap) super.metaPropertyMap(),
        "classifier",
        "securityProvider",
        "securityMaster");

    /**
     * Restricted constructor.
     */
    protected Meta() {
    }

    @Override
    protected MetaProperty<?> metaPropertyGet(String propertyName) {
      switch (propertyName.hashCode()) {
        case -281470431:  // classifier
          return _classifier;
        case 809869649:  // securityProvider
          return _securityProvider;
        case -887218750:  // securityMaster
          return _securityMaster;
      }
      return super.metaPropertyGet(propertyName);
    }

    @Override
    public BeanBuilder<? extends ExampleSecurityLoaderComponentFactory> builder() {
      return new DirectBeanBuilder<ExampleSecurityLoaderComponentFactory>(new ExampleSecurityLoaderComponentFactory());
    }

    @Override
    public Class<? extends ExampleSecurityLoaderComponentFactory> beanType() {
      return ExampleSecurityLoaderComponentFactory.class;
    }

    @Override
    public Map<String, MetaProperty<?>> metaPropertyMap() {
      return _metaPropertyMap$;
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-property for the {@code classifier} property.
     * @return the meta-property, not null
     */
    public final MetaProperty<String> classifier() {
      return _classifier;
    }

    /**
     * The meta-property for the {@code securityProvider} property.
     * @return the meta-property, not null
     */
    public final MetaProperty<SecurityProvider> securityProvider() {
      return _securityProvider;
    }

    /**
     * The meta-property for the {@code securityMaster} property.
     * @return the meta-property, not null
     */
    public final MetaProperty<SecurityMaster> securityMaster() {
      return _securityMaster;
    }

    //-----------------------------------------------------------------------
    @Override
    protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
      switch (propertyName.hashCode()) {
        case -281470431:  // classifier
          return ((ExampleSecurityLoaderComponentFactory) bean).getClassifier();
        case 809869649:  // securityProvider
          return ((ExampleSecurityLoaderComponentFactory) bean).getSecurityProvider();
        case -887218750:  // securityMaster
          return ((ExampleSecurityLoaderComponentFactory) bean).getSecurityMaster();
      }
      return super.propertyGet(bean, propertyName, quiet);
    }

    @Override
    protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
      switch (propertyName.hashCode()) {
        case -281470431:  // classifier
          ((ExampleSecurityLoaderComponentFactory) bean).setClassifier((String) newValue);
          return;
        case 809869649:  // securityProvider
          ((ExampleSecurityLoaderComponentFactory) bean).setSecurityProvider((SecurityProvider) newValue);
          return;
        case -887218750:  // securityMaster
          ((ExampleSecurityLoaderComponentFactory) bean).setSecurityMaster((SecurityMaster) newValue);
          return;
      }
      super.propertySet(bean, propertyName, newValue, quiet);
    }

    @Override
    protected void validate(Bean bean) {
      JodaBeanUtils.notNull(((ExampleSecurityLoaderComponentFactory) bean)._classifier, "classifier");
      JodaBeanUtils.notNull(((ExampleSecurityLoaderComponentFactory) bean)._securityProvider, "securityProvider");
      super.validate(bean);
    }

  }

  ///CLOVER:ON
  //-------------------------- AUTOGENERATED END --------------------------
}<commit_msg>[PLAT-5659] Publish HTSLoader as REST<commit_after>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.examples.bloomberg.component;

import java.util.Map;

import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.loader.AbstractSecurityLoaderComponentFactory;
import com.opengamma.financial.security.DefaultSecurityLoader;
import com.opengamma.master.security.SecurityLoader;
import com.opengamma.master.security.SecurityMaster;
import com.opengamma.provider.security.SecurityProvider;

/**
 * Component factory that instantiates the security loader.
 */
@BeanDefinition
public class ExampleSecurityLoaderComponentFactory extends AbstractSecurityLoaderComponentFactory {
  
  /**
   * The security provider.
   */
  @PropertyDefinition(validate = "notNull")
  private SecurityProvider _securityProvider;
  /**
   * The security master.
   */
  @PropertyDefinition
  private SecurityMaster _securityMaster;

  //-------------------------------------------------------------------------
  @Override
  protected SecurityLoader createSecurityLoader(ComponentRepository repo) {
    return new DefaultSecurityLoader(getSecurityMaster(), getSecurityProvider());
  }

  //------------------------- AUTOGENERATED START -------------------------
  ///CLOVER:OFF
  /**
   * The meta-bean for {@code ExampleSecurityLoaderComponentFactory}.
   * @return the meta-bean, not null
   */
  public static ExampleSecurityLoaderComponentFactory.Meta meta() {
    return ExampleSecurityLoaderComponentFactory.Meta.INSTANCE;
  }

  static {
    JodaBeanUtils.registerMetaBean(ExampleSecurityLoaderComponentFactory.Meta.INSTANCE);
  }

  @Override
  public ExampleSecurityLoaderComponentFactory.Meta metaBean() {
    return ExampleSecurityLoaderComponentFactory.Meta.INSTANCE;
  }

  //-----------------------------------------------------------------------
  /**
   * Gets the security provider.
   * @return the value of the property, not null
   */
  public SecurityProvider getSecurityProvider() {
    return _securityProvider;
  }

  /**
   * Sets the security provider.
   * @param securityProvider  the new value of the property, not null
   */
  public void setSecurityProvider(SecurityProvider securityProvider) {
    JodaBeanUtils.notNull(securityProvider, "securityProvider");
    this._securityProvider = securityProvider;
  }

  /**
   * Gets the the {@code securityProvider} property.
   * @return the property, not null
   */
  public final Property<SecurityProvider> securityProvider() {
    return metaBean().securityProvider().createProperty(this);
  }

  //-----------------------------------------------------------------------
  /**
   * Gets the security master.
   * @return the value of the property
   */
  public SecurityMaster getSecurityMaster() {
    return _securityMaster;
  }

  /**
   * Sets the security master.
   * @param securityMaster  the new value of the property
   */
  public void setSecurityMaster(SecurityMaster securityMaster) {
    this._securityMaster = securityMaster;
  }

  /**
   * Gets the the {@code securityMaster} property.
   * @return the property, not null
   */
  public final Property<SecurityMaster> securityMaster() {
    return metaBean().securityMaster().createProperty(this);
  }

  //-----------------------------------------------------------------------
  @Override
  public ExampleSecurityLoaderComponentFactory clone() {
    return (ExampleSecurityLoaderComponentFactory) super.clone();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
      ExampleSecurityLoaderComponentFactory other = (ExampleSecurityLoaderComponentFactory) obj;
      return JodaBeanUtils.equal(getSecurityProvider(), other.getSecurityProvider()) &&
          JodaBeanUtils.equal(getSecurityMaster(), other.getSecurityMaster()) &&
          super.equals(obj);
    }
    return false;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash += hash * 31 + JodaBeanUtils.hashCode(getSecurityProvider());
    hash += hash * 31 + JodaBeanUtils.hashCode(getSecurityMaster());
    return hash ^ super.hashCode();
  }

  @Override
  public String toString() {
    StringBuilder buf = new StringBuilder(96);
    buf.append("ExampleSecurityLoaderComponentFactory{");
    int len = buf.length();
    toString(buf);
    if (buf.length() > len) {
      buf.setLength(buf.length() - 2);
    }
    buf.append('}');
    return buf.toString();
  }

  @Override
  protected void toString(StringBuilder buf) {
    super.toString(buf);
    buf.append("securityProvider").append('=').append(JodaBeanUtils.toString(getSecurityProvider())).append(',').append(' ');
    buf.append("securityMaster").append('=').append(JodaBeanUtils.toString(getSecurityMaster())).append(',').append(' ');
  }

  //-----------------------------------------------------------------------
  /**
   * The meta-bean for {@code ExampleSecurityLoaderComponentFactory}.
   */
  public static class Meta extends AbstractSecurityLoaderComponentFactory.Meta {
    /**
     * The singleton instance of the meta-bean.
     */
    static final Meta INSTANCE = new Meta();

    /**
     * The meta-property for the {@code securityProvider} property.
     */
    private final MetaProperty<SecurityProvider> _securityProvider = DirectMetaProperty.ofReadWrite(
        this, "securityProvider", ExampleSecurityLoaderComponentFactory.class, SecurityProvider.class);
    /**
     * The meta-property for the {@code securityMaster} property.
     */
    private final MetaProperty<SecurityMaster> _securityMaster = DirectMetaProperty.ofReadWrite(
        this, "securityMaster", ExampleSecurityLoaderComponentFactory.class, SecurityMaster.class);
    /**
     * The meta-properties.
     */
    private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
        this, (DirectMetaPropertyMap) super.metaPropertyMap(),
        "securityProvider",
        "securityMaster");

    /**
     * Restricted constructor.
     */
    protected Meta() {
    }

    @Override
    protected MetaProperty<?> metaPropertyGet(String propertyName) {
      switch (propertyName.hashCode()) {
        case 809869649:  // securityProvider
          return _securityProvider;
        case -887218750:  // securityMaster
          return _securityMaster;
      }
      return super.metaPropertyGet(propertyName);
    }

    @Override
    public BeanBuilder<? extends ExampleSecurityLoaderComponentFactory> builder() {
      return new DirectBeanBuilder<ExampleSecurityLoaderComponentFactory>(new ExampleSecurityLoaderComponentFactory());
    }

    @Override
    public Class<? extends ExampleSecurityLoaderComponentFactory> beanType() {
      return ExampleSecurityLoaderComponentFactory.class;
    }

    @Override
    public Map<String, MetaProperty<?>> metaPropertyMap() {
      return _metaPropertyMap$;
    }

    //-----------------------------------------------------------------------
    /**
     * The meta-property for the {@code securityProvider} property.
     * @return the meta-property, not null
     */
    public final MetaProperty<SecurityProvider> securityProvider() {
      return _securityProvider;
    }

    /**
     * The meta-property for the {@code securityMaster} property.
     * @return the meta-property, not null
     */
    public final MetaProperty<SecurityMaster> securityMaster() {
      return _securityMaster;
    }

    //-----------------------------------------------------------------------
    @Override
    protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
      switch (propertyName.hashCode()) {
        case 809869649:  // securityProvider
          return ((ExampleSecurityLoaderComponentFactory) bean).getSecurityProvider();
        case -887218750:  // securityMaster
          return ((ExampleSecurityLoaderComponentFactory) bean).getSecurityMaster();
      }
      return super.propertyGet(bean, propertyName, quiet);
    }

    @Override
    protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
      switch (propertyName.hashCode()) {
        case 809869649:  // securityProvider
          ((ExampleSecurityLoaderComponentFactory) bean).setSecurityProvider((SecurityProvider) newValue);
          return;
        case -887218750:  // securityMaster
          ((ExampleSecurityLoaderComponentFactory) bean).setSecurityMaster((SecurityMaster) newValue);
          return;
      }
      super.propertySet(bean, propertyName, newValue, quiet);
    }

    @Override
    protected void validate(Bean bean) {
      JodaBeanUtils.notNull(((ExampleSecurityLoaderComponentFactory) bean)._securityProvider, "securityProvider");
      super.validate(bean);
    }

  }

  ///CLOVER:ON
  //-------------------------- AUTOGENERATED END --------------------------
}
{'fraction_non_alphanumeric': 0.1587082659564349, 'fraction_numerical': 0.007894987158755825, 'mean_word_length': 2.7948023822414725, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4236586', 'n_tokens_mistral': 5346, 'n_tokens_neox': 5173, 'n_words': 1206}