/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.master.user;

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.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

/**
 * Result providing the event history of a role.
 * <p>
 * When a role master is queried for event history, this class is used to return the result.
 * It stores a list of events, in chronological order, representing changes that were made.
 * See {@link RoleEventHistoryRequest} for more details.
 */
@BeanDefinition
public class RoleEventHistoryResult extends EventHistoryResult {

  /**
   * Creates an instance.
   */
  protected RoleEventHistoryResult() {
  }

  /**
   * Creates an instance from a collection of events.
   * 
   * @param events  the collection of events to add, not null
   */
  public RoleEventHistoryResult(Iterable<HistoryEvent> events) {
    super(events);
  }

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

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

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

  //-----------------------------------------------------------------------
  @Override
  public RoleEventHistoryResult clone() {
    return JodaBeanUtils.cloneAlways(this);
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
      return super.equals(obj);
    }
    return false;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    return hash ^ super.hashCode();
  }

  @Override
  public String toString() {
    StringBuilder buf = new StringBuilder(32);
    buf.append("RoleEventHistoryResult{");
    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);
  }

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

    /**
     * The meta-properties.
     */
    private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
        this, (DirectMetaPropertyMap) super.metaPropertyMap());

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

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

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

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

    //-----------------------------------------------------------------------
  }

  ///CLOVER:ON
  //-------------------------- AUTOGENERATED END --------------------------
}
