text:
#pragma once
#include <aws/finspace-data/FinSpaceData_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/finspace-data/model/ChangeType.h>
#include <aws/finspace-data/model/SourceType.h>
#include <aws/core/utils/memory/stl/AWSMap.h>
#include <aws/finspace-data/model/FormatType.h>
#include <aws/core/utils/DateTime.h>
#include <aws/finspace-data/model/ChangesetStatus.h>
#include <aws/finspace-data/model/ErrorInfo.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
  class JsonView;
} // namespace Json
} // namespace Utils
namespace FinSpaceData
{
namespace Model
{

  /**
   *
A changeset is unit of data in a dataset.

See Also:
   AWS
   * API Reference

   */
  class AWS_FINSPACEDATA_API ChangesetInfo
  {
  public:
    ChangesetInfo();
    ChangesetInfo(Aws::Utils::Json::JsonView jsonValue);
    ChangesetInfo& operator=(Aws::Utils::Json::JsonView jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
Unique identifier for a changeset.

     */
    inline const Aws::String& GetId() const{ return m_id; }

    /**
     *
Unique identifier for a changeset.

     */
    inline bool IdHasBeenSet() const { return m_idHasBeenSet; }

    /**
     *
Unique identifier for a changeset.

     */
    inline void SetId(const Aws::String& value) { m_idHasBeenSet = true; m_id = value; }

    /**
     *
Unique identifier for a changeset.

     */
    inline void SetId(Aws::String&& value) { m_idHasBeenSet = true; m_id = std::move(value); }

    /**
     *
Unique identifier for a changeset.

     */
    inline void SetId(const char* value) { m_idHasBeenSet = true; m_id.assign(value); }

    /**
     *
Unique identifier for a changeset.

     */
    inline ChangesetInfo& WithId(const Aws::String& value) { SetId(value); return *this;}

    /**
     *
Unique identifier for a changeset.

     */
    inline ChangesetInfo& WithId(Aws::String&& value) { SetId(std::move(value)); return *this;}

    /**
     *
Unique identifier for a changeset.

     */
    inline ChangesetInfo& WithId(const char* value) { SetId(value); return *this;}

    /**
     *
The ARN identifier of the changeset.

     */
    inline const Aws::String& GetChangesetArn() const{ return m_changesetArn; }

    /**
     *
The ARN identifier of the changeset.

     */
    inline bool ChangesetArnHasBeenSet() const { return m_changesetArnHasBeenSet; }

    /**
     *
The ARN identifier of the changeset.

     */
    inline void SetChangesetArn(const Aws::String& value) { m_changesetArnHasBeenSet = true; m_changesetArn = value; }

    /**
     *
The ARN identifier of the changeset.

     */
    inline void SetChangesetArn(Aws::String&& value) { m_changesetArnHasBeenSet = true; m_changesetArn = std::move(value); }

    /**
     *
The ARN identifier of the changeset.

     */
    inline void SetChangesetArn(const char* value) { m_changesetArnHasBeenSet = true; m_changesetArn.assign(value); }

    /**
     *
The ARN identifier of the changeset.

     */
    inline ChangesetInfo& WithChangesetArn(const Aws::String& value) { SetChangesetArn(value); return *this;}

    /**
     *
The ARN identifier of the changeset.

     */
    inline ChangesetInfo& WithChangesetArn(Aws::String&& value) { SetChangesetArn(std::move(value)); return *this;}

    /**
     *
The ARN identifier of the changeset.

     */
    inline ChangesetInfo& WithChangesetArn(const char* value) { SetChangesetArn(value); return *this;}

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline const Aws::String& GetDatasetId() const{ return m_datasetId; }

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline bool DatasetIdHasBeenSet() const { return m_datasetIdHasBeenSet; }

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline void SetDatasetId(const Aws::String& value) { m_datasetIdHasBeenSet = true; m_datasetId = value; }

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline void SetDatasetId(Aws::String&& value) { m_datasetIdHasBeenSet = true; m_datasetId = std::move(value); }

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline void SetDatasetId(const char* value) { m_datasetIdHasBeenSet = true; m_datasetId.assign(value); }

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline ChangesetInfo& WithDatasetId(const Aws::String& value) { SetDatasetId(value); return *this;}

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline ChangesetInfo& WithDatasetId(Aws::String&& value) { SetDatasetId(std::move(value)); return *this;}

    /**
     *
The unique identifier for the FinSpace dataset in which the changeset is
     * created.

     */
    inline ChangesetInfo& WithDatasetId(const char* value) { SetDatasetId(value); return *this;}

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline const ChangeType& GetChangeType() const{ return m_changeType; }

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline bool ChangeTypeHasBeenSet() const { return m_changeTypeHasBeenSet; }

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline void SetChangeType(const ChangeType& value) { m_changeTypeHasBeenSet = true; m_changeType = value; }

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline void SetChangeType(ChangeType&& value) { m_changeTypeHasBeenSet = true; m_changeType = std::move(value); }

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline ChangesetInfo& WithChangeType(const ChangeType& value) { SetChangeType(value); return *this;}

    /**
     *
Change type indicates how a changeset is applied to a dataset.

     *
 REPLACE - Changeset is considered as a replacement to all prior
     * loaded changesets.

 APPEND - Changeset is
     * considered as an addition to the end of all prior loaded changesets.

     *

 MODIFY - Changeset is considered as a replacement to a
     * specific prior ingested changeset.

     */
    inline ChangesetInfo& WithChangeType(ChangeType&& value) { SetChangeType(std::move(value)); return *this;}

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline const SourceType& GetSourceType() const{ return m_sourceType; }

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline bool SourceTypeHasBeenSet() const { return m_sourceTypeHasBeenSet; }

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline void SetSourceType(const SourceType& value) { m_sourceTypeHasBeenSet = true; m_sourceType = value; }

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline void SetSourceType(SourceType&& value) { m_sourceTypeHasBeenSet = true; m_sourceType = std::move(value); }

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline ChangesetInfo& WithSourceType(const SourceType& value) { SetSourceType(value); return *this;}

    /**
     *
Type of the data source from which the files to create the changeset are
     * sourced.

 S3 - Amazon S3.

     */
    inline ChangesetInfo& WithSourceType(SourceType&& value) { SetSourceType(std::move(value)); return *this;}

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline const Aws::Map<Aws::String, Aws::String>& GetSourceParams() const{ return m_sourceParams; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline bool SourceParamsHasBeenSet() const { return m_sourceParamsHasBeenSet; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline void SetSourceParams(const Aws::Map<Aws::String, Aws::String>& value) { m_sourceParamsHasBeenSet = true; m_sourceParams = value; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline void SetSourceParams(Aws::Map<Aws::String, Aws::String>&& value) { m_sourceParamsHasBeenSet = true; m_sourceParams = std::move(value); }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& WithSourceParams(const Aws::Map<Aws::String, Aws::String>& value) { SetSourceParams(value); return *this;}

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& WithSourceParams(Aws::Map<Aws::String, Aws::String>&& value) { SetSourceParams(std::move(value)); return *this;}

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(const Aws::String& key, const Aws::String& value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(key, value); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(Aws::String&& key, const Aws::String& value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(std::move(key), value); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(const Aws::String& key, Aws::String&& value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(key, std::move(value)); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(Aws::String&& key, Aws::String&& value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(std::move(key), std::move(value)); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(const char* key, Aws::String&& value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(key, std::move(value)); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(Aws::String&& key, const char* value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(std::move(key), value); return *this; }

    /**
     *
Source path from which the files to create the changeset are sourced.

     */
    inline ChangesetInfo& AddSourceParams(const char* key, const char* value) { m_sourceParamsHasBeenSet = true; m_sourceParams.emplace(key, value); return *this; }

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline const FormatType& GetFormatType() const{ return m_formatType; }

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline bool FormatTypeHasBeenSet() const { return m_formatTypeHasBeenSet; }

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline void SetFormatType(const FormatType& value) { m_formatTypeHasBeenSet = true; m_formatType = value; }

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline void SetFormatType(FormatType&& value) { m_formatTypeHasBeenSet = true; m_formatType = std::move(value); }

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline ChangesetInfo& WithFormatType(const FormatType& value) { SetFormatType(value); return *this;}

    /**
     *
Format type of the input files loaded into the changeset.

     */
    inline ChangesetInfo& WithFormatType(FormatType&& value) { SetFormatType(std::move(value)); return *this;}

    /**
     *
Structure of the source file(s).

     */
    inline const Aws::Map<Aws::String, Aws::String>& GetFormatParams() const{ return m_formatParams; }

    /**
     *
Structure of the source file(s).

     */
    inline bool FormatParamsHasBeenSet() const { return m_formatParamsHasBeenSet; }

    /**
     *
Structure of the source file(s).

     */
    inline void SetFormatParams(const Aws::Map<Aws::String, Aws::String>& value) { m_formatParamsHasBeenSet = true; m_formatParams = value; }

    /**
     *
Structure of the source file(s).

     */
    inline void SetFormatParams(Aws::Map<Aws::String, Aws::String>&& value) { m_formatParamsHasBeenSet = true; m_formatParams = std::move(value); }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& WithFormatParams(const Aws::Map<Aws::String, Aws::String>& value) { SetFormatParams(value); return *this;}

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& WithFormatParams(Aws::Map<Aws::String, Aws::String>&& value) { SetFormatParams(std::move(value)); return *this;}

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(const Aws::String& key, const Aws::String& value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(key, value); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(Aws::String&& key, const Aws::String& value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(std::move(key), value); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(const Aws::String& key, Aws::String&& value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(key, std::move(value)); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(Aws::String&& key, Aws::String&& value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(std::move(key), std::move(value)); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(const char* key, Aws::String&& value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(key, std::move(value)); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(Aws::String&& key, const char* value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(std::move(key), value); return *this; }

    /**
     *
Structure of the source file(s).

     */
    inline ChangesetInfo& AddFormatParams(const char* key, const char* value) { m_formatParamsHasBeenSet = true; m_formatParams.emplace(key, value); return *this; }

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline const Aws::Utils::DateTime& GetCreateTimestamp() const{ return m_createTimestamp; }

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline bool CreateTimestampHasBeenSet() const { return m_createTimestampHasBeenSet; }

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline void SetCreateTimestamp(const Aws::Utils::DateTime& value) { m_createTimestampHasBeenSet = true; m_createTimestamp = value; }

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline void SetCreateTimestamp(Aws::Utils::DateTime&& value) { m_createTimestampHasBeenSet = true; m_createTimestamp = std::move(value); }

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline ChangesetInfo& WithCreateTimestamp(const Aws::Utils::DateTime& value) { SetCreateTimestamp(value); return *this;}

    /**
     *
The timestamp at which the changeset was created in FinSpace.

     */
    inline ChangesetInfo& WithCreateTimestamp(Aws::Utils::DateTime&& value) { SetCreateTimestamp(std::move(value)); return *this;}

    /**
     *
The status of changeset creation operation.

     */
    inline const ChangesetStatus& GetStatus() const{ return m_status; }

    /**
     *
The status of changeset creation operation.

     */
    inline bool StatusHasBeenSet() const { return m_statusHasBeenSet; }

    /**
     *
The status of changeset creation operation.

     */
    inline void SetStatus(const ChangesetStatus& value) { m_statusHasBeenSet = true; m_status = value; }

    /**
     *
The status of changeset creation operation.

     */
    inline void SetStatus(ChangesetStatus&& value) { m_statusHasBeenSet = true; m_status = std::move(value); }

    /**
     *
The status of changeset creation operation.

     */
    inline ChangesetInfo& WithStatus(const ChangesetStatus& value) { SetStatus(value); return *this;}

    /**
     *
The status of changeset creation operation.

     */
    inline ChangesetInfo& WithStatus(ChangesetStatus&& value) { SetStatus(std::move(value)); return *this;}

    /**
     *
The structure with error messages.

     */
    inline const ErrorInfo& GetErrorInfo() const{ return m_errorInfo; }

    /**
     *
The structure with error messages.

     */
    inline bool ErrorInfoHasBeenSet() const { return m_errorInfoHasBeenSet; }

    /**
     *
The structure with error messages.

     */
    inline void SetErrorInfo(const ErrorInfo& value) { m_errorInfoHasBeenSet = true; m_errorInfo = value; }

    /**
     *
The structure with error messages.

     */
    inline void SetErrorInfo(ErrorInfo&& value) { m_errorInfoHasBeenSet = true; m_errorInfo = std::move(value); }

    /**
     *
The structure with error messages.

     */
    inline ChangesetInfo& WithErrorInfo(const ErrorInfo& value) { SetErrorInfo(value); return *this;}

    /**
     *
The structure with error messages.

     */
    inline ChangesetInfo& WithErrorInfo(ErrorInfo&& value) { SetErrorInfo(std::move(value)); return *this;}

    /**
     *
Tags associated with the changeset.

     */
    inline const Aws::Map<Aws::String, Aws::String>& GetChangesetLabels() const{ return m_changesetLabels; }

    /**
     *
Tags associated with the changeset.

     */
    inline bool ChangesetLabelsHasBeenSet() const { return m_changesetLabelsHasBeenSet; }

    /**
     *
Tags associated with the changeset.

     */
    inline void SetChangesetLabels(const Aws::Map<Aws::String, Aws::String>& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels = value; }

    /**
     *
Tags associated with the changeset.

     */
    inline void SetChangesetLabels(Aws::Map<Aws::String, Aws::String>&& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels = std::move(value); }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& WithChangesetLabels(const Aws::Map<Aws::String, Aws::String>& value) { SetChangesetLabels(value); return *this;}

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& WithChangesetLabels(Aws::Map<Aws::String, Aws::String>&& value) { SetChangesetLabels(std::move(value)); return *this;}

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(const Aws::String& key, const Aws::String& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(key, value); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(Aws::String&& key, const Aws::String& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(std::move(key), value); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(const Aws::String& key, Aws::String&& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(key, std::move(value)); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(Aws::String&& key, Aws::String&& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(std::move(key), std::move(value)); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(const char* key, Aws::String&& value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(key, std::move(value)); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(Aws::String&& key, const char* value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(std::move(key), value); return *this; }

    /**
     *
Tags associated with the changeset.

     */
    inline ChangesetInfo& AddChangesetLabels(const char* key, const char* value) { m_changesetLabelsHasBeenSet = true; m_changesetLabels.emplace(key, value); return *this; }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline const Aws::String& GetUpdatesChangesetId() const{ return m_updatesChangesetId; }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline bool UpdatesChangesetIdHasBeenSet() const { return m_updatesChangesetIdHasBeenSet; }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline void SetUpdatesChangesetId(const Aws::String& value) { m_updatesChangesetIdHasBeenSet = true; m_updatesChangesetId = value; }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline void SetUpdatesChangesetId(Aws::String&& value) { m_updatesChangesetIdHasBeenSet = true; m_updatesChangesetId = std::move(value); }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline void SetUpdatesChangesetId(const char* value) { m_updatesChangesetIdHasBeenSet = true; m_updatesChangesetId.assign(value); }

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline ChangesetInfo& WithUpdatesChangesetId(const Aws::String& value) { SetUpdatesChangesetId(value); return *this;}

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline ChangesetInfo& WithUpdatesChangesetId(Aws::String&& value) { SetUpdatesChangesetId(std::move(value)); return *this;}

    /**
     *
Unique identifier of the changeset that is updated.

     */
    inline ChangesetInfo& WithUpdatesChangesetId(const char* value) { SetUpdatesChangesetId(value); return *this;}

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline const Aws::String& GetUpdatedByChangesetId() const{ return m_updatedByChangesetId; }

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline bool UpdatedByChangesetIdHasBeenSet() const { return m_updatedByChangesetIdHasBeenSet; }

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline void SetUpdatedByChangesetId(const Aws::String& value) { m_updatedByChangesetIdHasBeenSet = true; m_updatedByChangesetId = value; }

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline void SetUpdatedByChangesetId(Aws::String&& value) { m_updatedByChangesetIdHasBeenSet = true; m_updatedByChangesetId = std::move(value); }

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline void SetUpdatedByChangesetId(const char* value) { m_updatedByChangesetIdHasBeenSet = true; m_updatedByChangesetId.assign(value); }

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline ChangesetInfo& WithUpdatedByChangesetId(const Aws::String& value) { SetUpdatedByChangesetId(value); return *this;}

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline ChangesetInfo& WithUpdatedByChangesetId(Aws::String&& value) { SetUpdatedByChangesetId(std::move(value)); return *this;}

    /**
     *
Unique identifier of the changeset that is updated a changeset.

     */
    inline ChangesetInfo& WithUpdatedByChangesetId(const char* value) { SetUpdatedByChangesetId(value); return *this;}

  private:

    Aws::String m_id;
    bool m_idHasBeenSet;

    Aws::String m_changesetArn;
    bool m_changesetArnHasBeenSet;

    Aws::String m_datasetId;
    bool m_datasetIdHasBeenSet;

    ChangeType m_changeType;
    bool m_changeTypeHasBeenSet;

    SourceType m_sourceType;
    bool m_sourceTypeHasBeenSet;

    Aws::Map<Aws::String, Aws::String> m_sourceParams;
    bool m_sourceParamsHasBeenSet;

    FormatType m_formatType;
    bool m_formatTypeHasBeenSet;

    Aws::Map<Aws::String, Aws::String> m_formatParams;
    bool m_formatParamsHasBeenSet;

    Aws::Utils::DateTime m_createTimestamp;
    bool m_createTimestampHasBeenSet;

    ChangesetStatus m_status;
    bool m_statusHasBeenSet;

    ErrorInfo m_errorInfo;
    bool m_errorInfoHasBeenSet;

    Aws::Map<Aws::String, Aws::String> m_changesetLabels;
    bool m_changesetLabelsHasBeenSet;

    Aws::String m_updatesChangesetId;
    bool m_updatesChangesetIdHasBeenSet;

    Aws::String m_updatedByChangesetId;
    bool m_updatedByChangesetIdHasBeenSet;
  };

} // namespace Model
} // namespace FinSpaceData
} // namespace Aws


text:
LDPlugin::LDPlugin(QWidget *parent, QString id) : QFrame(parent){
  PLUGID=id;
  prefix = id.replace("/","_")+"/";
  //qDebug() << "ID:" << PLUGID << prefix;
  settings = LSession::handle()->DesktopPluginSettings();
  //Use plugin-specific values for stylesheet control (applauncher, desktopview, etc...)
  this->setObjectName(id.section("---",0,0).section("::",0,0));
  connect(QApplication::instance(), SIGNAL(LocaleChanged()), this, SLOT(LocaleChange()) );
  connect(QApplication::instance(), SIGNAL(IconThemeChanged()), this, SLOT(ThemeChange()) );
}

void LDPlugin::setInitialSize(int width, int height){
    //Note: Only run this in the plugin initization routine:
    //  if the plugin is completely new (first time used), it will be this size
    if(settings->allKeys().filter(prefix+"location").isEmpty()){
	//Brand new plugin: set initial size
	//qDebug() << "Setting Initial Size:" << PLUGID << width << height;
	settings->setValue(prefix+"location/width",width);
	settings->setValue(prefix+"location/height",height);
	settings->sync();
    }
    //Now make sure the plugin is the saved size right away
    this->resize( settings->value(prefix+"location/width").toInt(), settings->value(prefix+"location/height").toInt());
}

void LDPlugin::adjustSize(int width, int height){
  settings->setValue(prefix+"location/width",width);
  settings->setValue(prefix+"location/height",height);
  settings->sync();
  this->resize(width,height);
  emit PluginResized();
}

redpajama_set_name: RedPajamaGithub


text:
class GoalsController < ApplicationController

  def index
    @goals = Goal.all.includes(:team).where(match_id: params[:match_id]).search(params[:q]).result.page(params[:page]).order(:minute)
    respond_with @goals
  end

  def create
    params[:goal] ||= {}

    if name = params[:goal][:team]
      t = Team.where(name: name.capitalize).first
      if t
        params[:goal][:team_id] = t.id
        params[:goal][:team] = nil
      end
    end

    @match = Match.find params[:match_id]
    @goal = @match.goals.create! goal_params

    respond_with @match, status: :created, location: @match
  end

  def update
    @goal = Goal.find params[:id]
    @goal.update_attributes!(goal_params)

    respond_with @goal, status: :ok
  end

  def destroy
    @goal = Goal.find params[:id]
    if @goal.destroy
      render json: {status: 'ok'}, status: :ok
    else
      respond_with @goal.errors, status: :unprocessable_entity
    end
  end

  private

  def goal_params
    params.require(:goal).permit(:scorer, :minute, :penalty, :own_goal, :team, :team_id)
  end
end


text:
habitat_core::env_config_int!(/// The number of times that a rumor will be shared with a given
                              /// member before we stop sending it to that same member.
                              ///
                              /// This is roughly analogous to the parameter `k` (used as a
                              /// blind counter) in the paper _Epidemic Algorithms for
                              /// Replicated Database Maintenance_ by Demers, et al., Section
                              /// 1.4 "Complex Epidemics", subsection "Variations".
                              ///
                              /// (To correspond more closely with the paper, this should be used
                              /// on a per rumor basis, though,
                              /// instead of a per rumor/member basis. As
                              /// it is, this Supervisor will share each rumor `RumorShareLimit*n`
                              /// times, where `n` is the number of Supervisors in the network.)
                              #[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq)]
                              RumorShareLimit,
                              usize,
                              HAB_RUMOR_SHARE_LIMIT,
                              2);

pub(crate) mod sync {
    use super::*;
    use crate::rumor::{RumorKey,
                       RumorType};
    use habitat_common::sync::{Lock,
                               ReadGuard,
                               WriteGuard};
    use std::collections::HashMap;

    type RumorHeatInner = HashMap<RumorKey, HashMap<String, usize>>;

    pub struct RumorHeatReadGuard<'a>(ReadGuard<'a, RumorHeatInner>);

    impl<'a> RumorHeatReadGuard<'a> {
        fn new(lock: &'a Lock<RumorHeatInner>) -> Self { Self(lock.read()) }

        /// Return a list of currently "hot" rumors for the specified
        /// member. This will be the subset of all rumors being tracked
        /// which have not already been sent to the member more than
        /// `RUMOR_COOL_DOWN_LIMIT` times.
        ///
        /// These rumors will be sorted by their "heat"; coldest rumors
        /// first, hotter rumors later. That is, rumors that have been
        /// shared `RUMOR_COOL_DOWN_LIMIT - 1` times will come first,
        /// followed by those that have been shared `RUMOR_COOL_DOWN_LIMIT
        /// -2` times, and so on, with those that have _never_ been
        /// shared with the member coming last.
        ///
        /// **NOTE**: The ordering of rumors within each of these "heat"
        /// cohorts is currently undefined.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (read)
        pub fn currently_hot_rumors(&self, id: &str) -> Vec<RumorKey> {
            let mut rumor_heat: Vec<(RumorKey, usize)> =
                self.0
                    .iter()
                    .map(|(k, heat_map)| (k.clone(), *heat_map.get(id).unwrap_or(&0)))
                    .filter(|&(_, heat)| heat < RumorShareLimit::configured_value().0)
                    .collect();

            // Reverse sorting by heat; 0s come last!
            rumor_heat.sort_by(|&(_, ref h1), &(_, ref h2)| h2.cmp(h1));

            // We don't need the heat anymore, just return the rumors.
            rumor_heat.into_iter().map(|(k, _)| k).collect()
        }
    }

    pub struct RumorHeatWriteGuard<'a>(WriteGuard<'a, RumorHeatInner>);

    impl<'a> RumorHeatWriteGuard<'a> {
        fn new(lock: &'a Lock<RumorHeatInner>) -> Self { Self(lock.write()) }

        /// Add a rumor to track; members will see it as "hot".
        ///
        /// If the rumor was already being tracked, we reset all
        /// previously-recorded "heat" information; the rumor is once
        /// again "hot" for _all_ members.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (write)
        pub fn start_hot_rumor<T: Into<RumorKey>>(&mut self, rumor: T) {
            self.0.insert(rumor.into(), Default::default());
        }

        /// For each rumor given, "cool" the rumor for the given member by
        /// incrementing the count for how many times it has been sent
        /// out. As a rumor cools, it will eventually cross a threshold
        /// past which it will no longer be gossipped to the member.
        ///
        /// Call this after sending rumors out across the network.
        ///
        /// **NOTE**: "cool" in the name of the function is a *verb*; you're
        /// not going to get a list of cool rumors from this.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (write)
        pub fn cool_rumors(&mut self, id: &str, rumors: &[RumorKey]) {
            if !rumors.is_empty() {
                for rk in rumors {
                    if self.0.contains_key(&rk) {
                        let heat_map = self.0.get_mut(&rk).unwrap();

                        if heat_map.contains_key(id) {
                            let heat = heat_map.get_mut(id).unwrap();
                            *heat += 1;
                        } else {
                            heat_map.insert(String::from(id), 1);
                        }
                    } else {
                        debug!("Rumor does not exist in map; was probably deleted between \
                                retrieval and sending");
                    }
                }
            }
        }

        /// When a member is considered "gone" (e.g., once it is
        /// considered Departed), we can get rid of all the "cooling"
        /// information, since we're not going to be sending anything
        /// their way again.
        ///
        /// Without this, we would continue carrying around this
        /// information for Supervisors that we're never going to see
        /// again. The larger the network of Supervisors is, the more
        /// memory this consumes. If that member should ever come back
        /// again, all rumors would be considered "hot" for them, so they
        /// will get a bit more network traffic initially.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (write)
        pub fn purge(&mut self, id: &str) {
            // Remove any information about Service rumors for this
            // particular member... it's leaving, so none of its services
            // will be around either.
            let count_before = self.0.len();
            self.0
                .retain(|k, _| !(k.kind == RumorType::Service && k.id == id));
            let count_after = self.0.len();
            debug!("Purged {} service rumor mappings for {:?}",
                   count_before - count_after,
                   id);

            // Remove any "cooling" information for this member, across
            // all types of rumors.
            let mut count = 0;
            for heat in self.0.values_mut() {
                if heat.remove(id).is_some() {
                    count += 1;
                }
            }
            debug!("Purged {} heat count entries for {:?}", count, id);
        }
    }

    /// Tracks the number of times a given rumor has been sent to each
    /// member of the supervision ring. This models the "heat" of a
    /// rumor; if a member has never heard it, it's "hot", but it "cools
    /// off" with each successive hearing.
    ///
    /// When a rumor changes, we can effectively reset things by starting
    /// the rumor mill up again. This will zero out all counters for every
    /// member, starting the sharing cycle over again.
    #[derive(Debug, Default)]
    pub struct RumorHeat {
        inner: Lock<RumorHeatInner>,
    }

    impl RumorHeat {
        #[must_use]
        pub fn lock_rhr(&self) -> RumorHeatReadGuard { RumorHeatReadGuard::new(&self.inner) }

        #[must_use]
        pub fn lock_rhw(&self) -> RumorHeatWriteGuard { RumorHeatWriteGuard::new(&self.inner) }
    }

    #[cfg(test)]
    pub(crate) mod tests {
        use super::*;
        use crate::{member::Member,
                    rumor::{service::{Service,
                                      SysInfo},
                            RumorKey}};
        use habitat_core::{locked_env_var,
                           package::PackageIdent,
                           service::ServiceGroup};

        locked_env_var!(HAB_RUMOR_SHARE_LIMIT, lock_rumor_limit);

        fn test_service(member_id: &str) -> Service {
            let package: PackageIdent = "core/foo/1.0.0/20180701125610".parse().unwrap();
            let sg = ServiceGroup::new("foo", "default", None).unwrap();
            Service::new(member_id, &package, sg, SysInfo::default(), None)
        }

        fn test_member(member_id: &str) -> Member {
            let mut m = Member::default();
            m.id = member_id.to_string();
            m
        }

        /// Helper function that tests that a given rumor is currently
        /// considered "hot" for the given member.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (read)
        pub fn assert_rumor_is_hot_rhr<T>(heat: &RumorHeat, member_id: &str, rumor: T)
            where T: Into<RumorKey>
        {
            let key = rumor.into();
            let hot_rumors = heat.lock_rhr().currently_hot_rumors(&member_id);
            assert!(hot_rumors.contains(&key));
        }

        /// Helper function that tests that a given rumor is currently
        /// NOT considered "hot" for the given member.
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (read)
        pub fn assert_rumor_is_cold_rhr<T>(heat: &RumorHeat, member_id: &str, rumor: T)
            where T: Into<RumorKey>
        {
            let key = rumor.into();
            let hot_rumors = heat.lock_rhr().currently_hot_rumors(&member_id);
            assert!(!hot_rumors.contains(&key));
        }

        /// Helper function that takes a rumor that has already been
        /// introduced into the `RumorHeat` and cools it enough to no
        /// longer be considered "hot".
        ///
        /// # Locking (see locking.md)
        /// * `RumorHeat::inner` (write)
        pub fn cool_rumor_completely_rhw<T>(heat: &RumorHeat, member_id: &str, rumor: T)
            where T: Into<RumorKey>
        {
            let rumor_keys = &[rumor.into()];
            for _ in 0..RumorShareLimit::default().0 {
                heat.lock_rhw().cool_rumors(&member_id, rumor_keys);
            }
        }

        #[test]
        fn purging_removes_heat_information_for_a_given_member() {
            let l = lock_rumor_limit();
            l.unset();

            // Here's our world... we've got 3 members. We'll have a
            // Service rumor and a Member rumor for each of them. Then,
            // we'll ensure that all rumors have cooled for all members,
            // which will totally fill the RumorHeat structure.
            //
            // Then we'll purge member 2.
            //
            // We'll expect the entry for rumor for the service running on
            // member 2 to be completely gone, while only the "heat"
            // information for member 2 is removed from all other entries.

            let heat = RumorHeat::default();

            let member_1_id = "test_member_1";
            let member_2_id = "test_member_2";
            let member_3_id = "test_member_3";

            let member_1 = test_member(&member_1_id);
            let member_2 = test_member(&member_2_id);
            let member_3 = test_member(&member_3_id);

            let service_1 = test_service(&member_1_id);
            let service_2 = test_service(&member_2_id);
            let service_3 = test_service(&member_3_id);

            // We're going to add a bunch of rumors, and then ensure
            // they're completely "cooled" for every member. This should
            // approximate a long-standing, stable network, where all
            // rumors have been disseminated to all members.
            heat.lock_rhw().start_hot_rumor(&member_1);
            heat.lock_rhw().start_hot_rumor(&member_2);
            heat.lock_rhw().start_hot_rumor(&member_3);
            heat.lock_rhw().start_hot_rumor(&service_1);
            heat.lock_rhw().start_hot_rumor(&service_2);
            heat.lock_rhw().start_hot_rumor(&service_3);

            for m in &[member_1_id, member_2_id, member_3_id] {
                cool_rumor_completely_rhw(&heat, m, &service_1);
                cool_rumor_completely_rhw(&heat, m, &service_2);
                cool_rumor_completely_rhw(&heat, m, &service_3);
                cool_rumor_completely_rhw(&heat, m, &member_1);
                cool_rumor_completely_rhw(&heat, m, &member_2);
                cool_rumor_completely_rhw(&heat, m, &member_3);
            }

            // Peek at the internals; the purge method is basically about
            // reclaiming memory.
            //
            // This just asserts our baseline.
            {
                let inner = heat.lock_rhr().0;
                assert_eq!(inner.len(), 6);

                // Check the Member rumors
                for m in &[&member_1, &member_2, &member_3] {
                    let heat_map = inner.get(&RumorKey::from(*m))
                                        .expect("Should have had a member rumor present");
                    for m in &[member_1_id, member_2_id, member_3_id] {
                        assert_eq!(heat_map.get(*m)
                                           .expect("Should have had an entry for the member"),
                                   &RumorShareLimit::default().0);
                    }
                }

                // Check the Service rumors
                for s in &[&service_1, &service_2, &service_3] {
                    let heat_map = inner.get(&RumorKey::from(*s))
                                        .expect("Should have had a service rumor present");
                    for m in &[member_1_id, member_2_id, member_3_id] {
                        assert_eq!(heat_map.get(*m)
                                           .expect("Should have had an entry for the member"),
                                   &RumorShareLimit::default().0);
                    }
                }
            }

            // This is the meat of the test
            heat.lock_rhw().purge(&member_2_id);

            // Now we peek at the internals again, verifying that only the
            // information pertaining to member 2 is gone.
            {
                let inner = heat.lock_rhr().0;
                assert_eq!(inner.len(), 5);

                // Check the Member rumors... all these should be present
                for m in &[&member_1, &member_2, &member_3] {
                    let heat_map = inner.get(&RumorKey::from(*m))
                                        .expect("Should have had a member rumor present");
                    assert_eq!(heat_map.get(member_1_id).expect("lulz"),
                               &RumorShareLimit::default().0);
                    assert!(heat_map.get(member_2_id).is_none(),
                            "Heat information for a purged member should be removed");
                    assert_eq!(heat_map.get(member_3_id).expect("lulz"),
                               &RumorShareLimit::default().0);
                }

                // Check the Service rumors
                assert!(inner.get(&RumorKey::from(&service_2)).is_none(),
                        "Service keys from the purged member should be removed");
                for s in &[&service_1, &service_3] {
                    let heat_map = inner.get(&RumorKey::from(*s))
                                        .expect("Should have had a service rumor present");
                    assert_eq!(heat_map.get(member_1_id).expect("lulz"),
                               &RumorShareLimit::default().0);
                    assert!(heat_map.get(member_2_id).is_none(),
                            "Heat information for a purged member should be removed");
                    assert_eq!(heat_map.get(member_3_id).expect("lulz"),
                               &RumorShareLimit::default().0);
                }
            }
        }
    }
}

#[cfg(test)]
mod tests {
    use super::{sync::{tests::{assert_rumor_is_cold_rhr,
                               assert_rumor_is_hot_rhr,
                               cool_rumor_completely_rhw},
                       RumorHeat},
                *};
    use crate::{error::Result,
                protocol::{self,
                           newscast},
                rumor::{Rumor,
                        RumorKey,
                        RumorType}};
    use habitat_core::locked_env_var;
    use uuid::Uuid;

    locked_env_var!(HAB_RUMOR_SHARE_LIMIT, lock_rumor_limit);

    // TODO (CM): This FakeRumor implementation is copied from
    // rumor.rs; factor this helper code better.

    #[derive(Clone, Debug, Serialize)]
    struct FakeRumor {
        pub id:  String,
        pub key: String,
    }

    impl Default for FakeRumor {
        fn default() -> FakeRumor {
            FakeRumor { id:  format!("{}", Uuid::new_v4().to_simple_ref()),
                        key: String::from("fakerton"), }
        }
    }

    impl Rumor for FakeRumor {
        fn kind(&self) -> RumorType { RumorType::Fake }

        fn key(&self) -> &str { &self.key }

        fn id(&self) -> &str { &self.id }

        fn merge(&mut self, mut _other: FakeRumor) -> bool { false }
    }

    impl protocol::FromProto<newscast::Rumor> for FakeRumor {
        fn from_proto(_other: newscast::Rumor) -> Result<Self> { Ok(FakeRumor::default()) }
    }

    impl From<FakeRumor> for newscast::Rumor {
        fn from(_other: FakeRumor) -> newscast::Rumor { newscast::Rumor::default() }
    }

    impl protocol::Message<newscast::Rumor> for FakeRumor {
        const MESSAGE_ID: &'static str = "FakeRumor";

        fn from_bytes(_bytes: &[u8]) -> Result<Self> { Ok(FakeRumor::default()) }

        fn write_to_bytes(&self) -> Result<Vec<u8>> {
            Ok(Vec::from(format!("{}-{}", self.id, self.key).as_bytes()))
        }
    }

    #[test]
    fn there_are_no_hot_rumors_to_begin_with() {
        let heat = RumorHeat::default();
        let member_id = "test_member";

        let hot_rumors = heat.lock_rhr().currently_hot_rumors(&member_id);
        assert!(hot_rumors.is_empty());
    }

    #[test]
    fn a_hot_rumor_is_returned_as_such() {
        let l = lock_rumor_limit();
        l.unset();

        let heat = RumorHeat::default();
        let member_id = "test_member";
        let rumor = FakeRumor::default();

        heat.lock_rhw().start_hot_rumor(&rumor);

        let hot_rumors = heat.lock_rhr().currently_hot_rumors(&member_id);
        assert_eq!(hot_rumors.len(), 1);
        assert_eq!(hot_rumors[0], RumorKey::from(&rumor));
    }

    #[test]
    fn a_hot_rumor_eventually_cools_off() {
        let l = lock_rumor_limit();
        l.unset();

        let heat = RumorHeat::default();
        let member_id = "test_member";
        let rumor = FakeRumor::default();
        let rumor_key = RumorKey::from(&rumor);
        let rumor_keys = &[rumor_key.clone()];

        heat.lock_rhw().start_hot_rumor(&rumor);

        // Simulate going through the requisite number of gossip
        // cycles to cool the rumor down
        //
        // Not using the helper function here, as this function is
        // what this test is actually testing.
        for _ in 0..RumorShareLimit::default().0 {
            assert_rumor_is_hot_rhr(&heat, &member_id, &rumor);
            heat.lock_rhw().cool_rumors(&member_id, rumor_keys);
        }

        // At this point, our member should have heard this rumor
        // enough that it's no longer hot
        let hot_rumors = heat.lock_rhr().currently_hot_rumors(&member_id);
        assert!(!hot_rumors.contains(&rumor_key));
    }

    #[test]
    fn rumors_can_become_hot_again_by_restarting_them() {
        let l = lock_rumor_limit();
        l.unset();

        let heat = RumorHeat::default();
        let member_id = "test_member";
        let rumor = FakeRumor::default();

        heat.lock_rhw().start_hot_rumor(&rumor);

        // Simulate going through the requisite number of gossip
        // cycles to cool the rumor down
        cool_rumor_completely_rhw(&heat, &member_id, &rumor);

        // At this point, our member should have heard this rumor
        // enough that it's no longer hot
        assert_rumor_is_cold_rhr(&heat, &member_id, &rumor);

        // NOW we'll start the rumor again!
        heat.lock_rhw().start_hot_rumor(&rumor);

        // Rumors... *so hot right now*
        assert_rumor_is_hot_rhr(&heat, &member_id, &rumor);
    }

    #[test]
    fn rumor_heat_is_tracked_per_member() {
        let l = lock_rumor_limit();
        l.unset();

        let heat = RumorHeat::default();
        let member_one = "test_member_1";
        let member_two = "test_member_2";
        let rumor = FakeRumor::default();

        heat.lock_rhw().start_hot_rumor(&rumor);

        // Both members should see the rumor as hot.
        assert_rumor_is_hot_rhr(&heat, &member_one, &rumor);
        assert_rumor_is_hot_rhr(&heat, &member_two, &rumor);

        // Now, let's cool the rumor for only one of the members
        cool_rumor_completely_rhw(&heat, &member_one, &rumor);

        // Now it should be cold for the one member, but still hot
        // for the other.
        assert_rumor_is_cold_rhr(&heat, &member_one, &rumor);
        assert_rumor_is_hot_rhr(&heat, &member_two, &rumor);
    }

    #[test]
    fn hot_rumors_are_sorted_colder_to_warmer() {
        let l = lock_rumor_limit();
        l.unset();

        let heat = RumorHeat::default();
        let member = "test_member";

        // TODO (CM): for ease of test reading (esp. with failures), I'd like fake
        // rumors that I can control the IDs
        let hot_rumor = FakeRumor::default();
        let warm_rumor = FakeRumor::default();
        let cold_rumor = FakeRumor::default();

        // Start all rumors off as hot
        heat.lock_rhw().start_hot_rumor(&hot_rumor);
        heat.lock_rhw().start_hot_rumor(&warm_rumor);
        heat.lock_rhw().start_hot_rumor(&cold_rumor);

        // Cool some rumors off, to varying degrees
        let hot_key = RumorKey::from(&hot_rumor);
        let warm_key = RumorKey::from(&warm_rumor);

        // Freeze this one right out
        cool_rumor_completely_rhw(&heat, &member, &cold_rumor);

        // Cool this one off just a little bit
        heat.lock_rhw().cool_rumors(&member, &[warm_key.clone()]);

        // cold_rumor should be completely out, and the cooler
        // rumor sorts before the hotter one.
        let rumors = heat.lock_rhr().currently_hot_rumors(&member);
        let expected_hot_rumors = &[warm_key, hot_key];
        assert_eq!(rumors, expected_hot_rumors);
    }
}


text:
package com.google.android.exoplayer2.ui;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import java.util.Formatter;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * A time bar that shows a current position, buffered position, duration and ad markers.
 *
 *
A DefaultTimeBar can be customized by setting attributes, as outlined below.
 *
 *
Attributes

 *
 * The following attributes can be set on a DefaultTimeBar when used in a layout XML file:
 *
 *

 *
 *

 *
{@code bar_height} - Dimension for the height of the time bar.
 *

 *
Default: {@link #DEFAULT_BAR_HEIGHT_DP}
 *

 *
{@code touch_target_height} - Dimension for the height of the area in which touch
 *       interactions with the time bar are handled. If no height is specified, this also determines
 *       the height of the view.
 *

 *
Default: {@link #DEFAULT_TOUCH_TARGET_HEIGHT_DP}
 *

 *
{@code ad_marker_width} - Dimension for the width of any ad markers shown on the
 *       bar. Ad markers are superimposed on the time bar to show the times at which ads will play.
 *

 *
Default: {@link #DEFAULT_AD_MARKER_WIDTH_DP}
 *

 *
{@code scrubber_enabled_size} - Dimension for the diameter of the circular scrubber
 *       handle when scrubbing is enabled but not in progress. Set to zero if no scrubber handle
 *       should be shown.
 *

 *
Default: {@link #DEFAULT_SCRUBBER_ENABLED_SIZE_DP}
 *

 *
{@code scrubber_disabled_size} - Dimension for the diameter of the circular scrubber
 *       handle when scrubbing isn't enabled. Set to zero if no scrubber handle should be shown.
 *

 *
Default: {@link #DEFAULT_SCRUBBER_DISABLED_SIZE_DP}
 *

 *
{@code scrubber_dragged_size} - Dimension for the diameter of the circular scrubber
 *       handle when scrubbing is in progress. Set to zero if no scrubber handle should be shown.
 *

 *
Default: {@link #DEFAULT_SCRUBBER_DRAGGED_SIZE_DP}
 *

 *
{@code scrubber_drawable} - Optional reference to a drawable to draw for the
 *       scrubber handle. If set, this overrides the default behavior, which is to draw a circle for
 *       the scrubber handle.
 *
{@code played_color} - Color for the portion of the time bar representing media
 *       before the current playback position.
 *

 *
Corresponding method: {@link #setPlayedColor(int)}
 *
Default: {@link #DEFAULT_PLAYED_COLOR}
 *

 *
{@code scrubber_color} - Color for the scrubber handle.
 *

 *
Corresponding method: {@link #setScrubberColor(int)}
 *
Default: see {@link #getDefaultScrubberColor(int)}
 *

 *
{@code buffered_color} - Color for the portion of the time bar after the current
 *       played position up to the current buffered position.
 *

 *
Corresponding method: {@link #setBufferedColor(int)}
 *
Default: see {@link #getDefaultBufferedColor(int)}
 *

 *
{@code unplayed_color} - Color for the portion of the time bar after the current
 *       buffered position.
 *

 *
Corresponding method: {@link #setUnplayedColor(int)}
 *
Default: see {@link #getDefaultUnplayedColor(int)}
 *

 *
{@code ad_marker_color} - Color for unplayed ad markers.
 *

 *
Corresponding method: {@link #setAdMarkerColor(int)}
 *
Default: {@link #DEFAULT_AD_MARKER_COLOR}
 *

 *
{@code played_ad_marker_color} - Color for played ad markers.
 *

 *
Corresponding method: {@link #setPlayedAdMarkerColor(int)}
 *
Default: see {@link #getDefaultPlayedAdMarkerColor(int)}
 *

 *

 */
public class DefaultTimeBar extends View implements TimeBar {

  /**
   * Default height for the time bar, in dp.
   */
  public static final int DEFAULT_BAR_HEIGHT_DP = 4;
  /**
   * Default height for the touch target, in dp.
   */
  public static final int DEFAULT_TOUCH_TARGET_HEIGHT_DP = 26;
  /**
   * Default width for ad markers, in dp.
   */
  public static final int DEFAULT_AD_MARKER_WIDTH_DP = 4;
  /**
   * Default diameter for the scrubber when enabled, in dp.
   */
  public static final int DEFAULT_SCRUBBER_ENABLED_SIZE_DP = 12;
  /**
   * Default diameter for the scrubber when disabled, in dp.
   */
  public static final int DEFAULT_SCRUBBER_DISABLED_SIZE_DP = 0;
  /**
   * Default diameter for the scrubber when dragged, in dp.
   */
  public static final int DEFAULT_SCRUBBER_DRAGGED_SIZE_DP = 16;
  /**
   * Default color for the played portion of the time bar.
   */
  public static final int DEFAULT_PLAYED_COLOR = 0xFFFFFFFF;
  /**
   * Default color for ad markers.
   */
  public static final int DEFAULT_AD_MARKER_COLOR = 0xB2FFFF00;

  /**
   * The threshold in dps above the bar at which touch events trigger fine scrub mode.
   */
  private static final int FINE_SCRUB_Y_THRESHOLD_DP = -50;
  /**
   * The ratio by which times are reduced in fine scrub mode.
   */
  private static final int FINE_SCRUB_RATIO = 3;
  /**
   * The time after which the scrubbing listener is notified that scrubbing has stopped after
   * performing an incremental scrub using key input.
   */
  private static final long STOP_SCRUBBING_TIMEOUT_MS = 1000;
  private static final int DEFAULT_INCREMENT_COUNT = 20;

  /**
   * The name of the Android SDK view that most closely resembles this custom view. Used as the
   * class name for accessibility.
   */
  private static final String ACCESSIBILITY_CLASS_NAME = "android.widget.SeekBar";

  private final Rect seekBounds;
  private final Rect progressBar;
  private final Rect bufferedBar;
  private final Rect scrubberBar;
  private final Paint playedPaint;
  private final Paint bufferedPaint;
  private final Paint unplayedPaint;
  private final Paint adMarkerPaint;
  private final Paint playedAdMarkerPaint;
  private final Paint scrubberPaint;
  private final @Nullable Drawable scrubberDrawable;
  private final int barHeight;
  private final int touchTargetHeight;
  private final int adMarkerWidth;
  private final int scrubberEnabledSize;
  private final int scrubberDisabledSize;
  private final int scrubberDraggedSize;
  private final int scrubberPadding;
  private final int fineScrubYThreshold;
  private final StringBuilder formatBuilder;
  private final Formatter formatter;
  private final Runnable stopScrubbingRunnable;
  private final CopyOnWriteArraySet<OnScrubListener> listeners;
  private final int[] locationOnScreen;
  private final Point touchPosition;
  private final float density;

  private int keyCountIncrement;
  private long keyTimeIncrement;
  private int lastCoarseScrubXPosition;

  private boolean scrubbing;
  private long scrubPosition;
  private long duration;
  private long position;
  private long bufferedPosition;
  private int adGroupCount;
  private @Nullable long[] adGroupTimesMs;
  private @Nullable boolean[] playedAdGroups;

  /** Creates a new time bar. */
  // Suppress warnings due to usage of View methods in the constructor.
  @SuppressWarnings("nullness:method.invocation.invalid")
  public DefaultTimeBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    seekBounds = new Rect();
    progressBar = new Rect();
    bufferedBar = new Rect();
    scrubberBar = new Rect();
    playedPaint = new Paint();
    bufferedPaint = new Paint();
    unplayedPaint = new Paint();
    adMarkerPaint = new Paint();
    playedAdMarkerPaint = new Paint();
    scrubberPaint = new Paint();
    scrubberPaint.setAntiAlias(true);
    listeners = new CopyOnWriteArraySet<>();
    locationOnScreen = new int[2];
    touchPosition = new Point();

    // Calculate the dimensions and paints for drawn elements.
    Resources res = context.getResources();
    DisplayMetrics displayMetrics = res.getDisplayMetrics();
    density = displayMetrics.density;
    fineScrubYThreshold = dpToPx(density, FINE_SCRUB_Y_THRESHOLD_DP);
    int defaultBarHeight = dpToPx(density, DEFAULT_BAR_HEIGHT_DP);
    int defaultTouchTargetHeight = dpToPx(density, DEFAULT_TOUCH_TARGET_HEIGHT_DP);
    int defaultAdMarkerWidth = dpToPx(density, DEFAULT_AD_MARKER_WIDTH_DP);
    int defaultScrubberEnabledSize = dpToPx(density, DEFAULT_SCRUBBER_ENABLED_SIZE_DP);
    int defaultScrubberDisabledSize = dpToPx(density, DEFAULT_SCRUBBER_DISABLED_SIZE_DP);
    int defaultScrubberDraggedSize = dpToPx(density, DEFAULT_SCRUBBER_DRAGGED_SIZE_DP);
    if (attrs != null) {
      TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DefaultTimeBar, 0,
          0);
      try {
        scrubberDrawable = a.getDrawable(R.styleable.DefaultTimeBar_scrubber_drawable);
        if (scrubberDrawable != null) {
          setDrawableLayoutDirection(scrubberDrawable);
          defaultTouchTargetHeight =
              Math.max(scrubberDrawable.getMinimumHeight(), defaultTouchTargetHeight);
        }
        barHeight = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_bar_height,
            defaultBarHeight);
        touchTargetHeight = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_touch_target_height,
            defaultTouchTargetHeight);
        adMarkerWidth = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_ad_marker_width,
            defaultAdMarkerWidth);
        scrubberEnabledSize = a.getDimensionPixelSize(
            R.styleable.DefaultTimeBar_scrubber_enabled_size, defaultScrubberEnabledSize);
        scrubberDisabledSize = a.getDimensionPixelSize(
            R.styleable.DefaultTimeBar_scrubber_disabled_size, defaultScrubberDisabledSize);
        scrubberDraggedSize = a.getDimensionPixelSize(
            R.styleable.DefaultTimeBar_scrubber_dragged_size, defaultScrubberDraggedSize);
        int playedColor = a.getInt(R.styleable.DefaultTimeBar_played_color, DEFAULT_PLAYED_COLOR);
        int scrubberColor = a.getInt(R.styleable.DefaultTimeBar_scrubber_color,
            getDefaultScrubberColor(playedColor));
        int bufferedColor = a.getInt(R.styleable.DefaultTimeBar_buffered_color,
            getDefaultBufferedColor(playedColor));
        int unplayedColor = a.getInt(R.styleable.DefaultTimeBar_unplayed_color,
            getDefaultUnplayedColor(playedColor));
        int adMarkerColor = a.getInt(R.styleable.DefaultTimeBar_ad_marker_color,
            DEFAULT_AD_MARKER_COLOR);
        int playedAdMarkerColor = a.getInt(R.styleable.DefaultTimeBar_played_ad_marker_color,
            getDefaultPlayedAdMarkerColor(adMarkerColor));
        playedPaint.setColor(playedColor);
        scrubberPaint.setColor(scrubberColor);
        bufferedPaint.setColor(bufferedColor);
        unplayedPaint.setColor(unplayedColor);
        adMarkerPaint.setColor(adMarkerColor);
        playedAdMarkerPaint.setColor(playedAdMarkerColor);
      } finally {
        a.recycle();
      }
    } else {
      barHeight = defaultBarHeight;
      touchTargetHeight = defaultTouchTargetHeight;
      adMarkerWidth = defaultAdMarkerWidth;
      scrubberEnabledSize = defaultScrubberEnabledSize;
      scrubberDisabledSize = defaultScrubberDisabledSize;
      scrubberDraggedSize = defaultScrubberDraggedSize;
      playedPaint.setColor(DEFAULT_PLAYED_COLOR);
      scrubberPaint.setColor(getDefaultScrubberColor(DEFAULT_PLAYED_COLOR));
      bufferedPaint.setColor(getDefaultBufferedColor(DEFAULT_PLAYED_COLOR));
      unplayedPaint.setColor(getDefaultUnplayedColor(DEFAULT_PLAYED_COLOR));
      adMarkerPaint.setColor(DEFAULT_AD_MARKER_COLOR);
      scrubberDrawable = null;
    }
    formatBuilder = new StringBuilder();
    formatter = new Formatter(formatBuilder, Locale.getDefault());
    stopScrubbingRunnable = () -> stopScrubbing(/* canceled= */ false);
    if (scrubberDrawable != null) {
      scrubberPadding = (scrubberDrawable.getMinimumWidth() + 1) / 2;
    } else {
      scrubberPadding =
          (Math.max(scrubberDisabledSize, Math.max(scrubberEnabledSize, scrubberDraggedSize)) + 1)
              / 2;
    }
    duration = C.TIME_UNSET;
    keyTimeIncrement = C.TIME_UNSET;
    keyCountIncrement = DEFAULT_INCREMENT_COUNT;
    setFocusable(true);
    if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
      setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
  }

  /**
   * Sets the color for the portion of the time bar representing media before the playback position.
   *
   * @param playedColor The color for the portion of the time bar representing media before the
   *     playback position.
   */
  public void setPlayedColor(@ColorInt int playedColor) {
    playedPaint.setColor(playedColor);
    invalidate(seekBounds);
  }

  /**
   * Sets the color for the scrubber handle.
   *
   * @param scrubberColor The color for the scrubber handle.
   */
  public void setScrubberColor(@ColorInt int scrubberColor) {
    scrubberPaint.setColor(scrubberColor);
    invalidate(seekBounds);
  }

  /**
   * Sets the color for the portion of the time bar after the current played position up to the
   * current buffered position.
   *
   * @param bufferedColor The color for the portion of the time bar after the current played
   *     position up to the current buffered position.
   */
  public void setBufferedColor(@ColorInt int bufferedColor) {
    bufferedPaint.setColor(bufferedColor);
    invalidate(seekBounds);
  }

  /**
   * Sets the color for the portion of the time bar after the current played position.
   *
   * @param unplayedColor The color for the portion of the time bar after the current played
   *     position.
   */
  public void setUnplayedColor(@ColorInt int unplayedColor) {
    unplayedPaint.setColor(unplayedColor);
    invalidate(seekBounds);
  }

  /**
   * Sets the color for unplayed ad markers.
   *
   * @param adMarkerColor The color for unplayed ad markers.
   */
  public void setAdMarkerColor(@ColorInt int adMarkerColor) {
    adMarkerPaint.setColor(adMarkerColor);
    invalidate(seekBounds);
  }

  /**
   * Sets the color for played ad markers.
   *
   * @param playedAdMarkerColor The color for played ad markers.
   */
  public void setPlayedAdMarkerColor(@ColorInt int playedAdMarkerColor) {
    playedAdMarkerPaint.setColor(playedAdMarkerColor);
    invalidate(seekBounds);
  }

  // TimeBar implementation.

  @Override
  public void addListener(OnScrubListener listener) {
    listeners.add(listener);
  }

  @Override
  public void removeListener(OnScrubListener listener) {
    listeners.remove(listener);
  }

  @Override
  public void setKeyTimeIncrement(long time) {
    Assertions.checkArgument(time > 0);
    keyCountIncrement = C.INDEX_UNSET;
    keyTimeIncrement = time;
  }

  @Override
  public void setKeyCountIncrement(int count) {
    Assertions.checkArgument(count > 0);
    keyCountIncrement = count;
    keyTimeIncrement = C.TIME_UNSET;
  }

  @Override
  public void setPosition(long position) {
    this.position = position;
    setContentDescription(getProgressText());
    update();
  }

  @Override
  public void setBufferedPosition(long bufferedPosition) {
    this.bufferedPosition = bufferedPosition;
    update();
  }

  @Override
  public void setDuration(long duration) {
    this.duration = duration;
    if (scrubbing && duration == C.TIME_UNSET) {
      stopScrubbing(/* canceled= */ true);
    }
    update();
  }

  @Override
  public long getPreferredUpdateDelay() {
    int timeBarWidthDp = pxToDp(density, progressBar.width());
    return timeBarWidthDp == 0 || duration == 0 || duration == C.TIME_UNSET
        ? Long.MAX_VALUE
        : duration / timeBarWidthDp;
  }

  @Override
  public void setAdGroupTimesMs(@Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups,
      int adGroupCount) {
    Assertions.checkArgument(adGroupCount == 0
        || (adGroupTimesMs != null && playedAdGroups != null));
    this.adGroupCount = adGroupCount;
    this.adGroupTimesMs = adGroupTimesMs;
    this.playedAdGroups = playedAdGroups;
    update();
  }

  // View methods.

  @Override
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);
    if (scrubbing && !enabled) {
      stopScrubbing(/* canceled= */ true);
    }
  }

  @Override
  public void onDraw(Canvas canvas) {
    canvas.save();
    drawTimeBar(canvas);
    drawPlayhead(canvas);
    canvas.restore();
  }

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled() || duration <= 0) {
      return false;
    }
    Point touchPosition = resolveRelativeTouchPosition(event);
    int x = touchPosition.x;
    int y = touchPosition.y;
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        if (isInSeekBar(x, y)) {
          positionScrubber(x);
          startScrubbing(getScrubberPosition());
          update();
          invalidate();
          return true;
        }
        break;
      case MotionEvent.ACTION_MOVE:
        if (scrubbing) {
          if (y < fineScrubYThreshold) {
            int relativeX = x - lastCoarseScrubXPosition;
            positionScrubber(lastCoarseScrubXPosition + relativeX / FINE_SCRUB_RATIO);
          } else {
            lastCoarseScrubXPosition = x;
            positionScrubber(x);
          }
          updateScrubbing(getScrubberPosition());
          update();
          invalidate();
          return true;
        }
        break;
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        if (scrubbing) {
          stopScrubbing(/* canceled= */ event.getAction() == MotionEvent.ACTION_CANCEL);
          return true;
        }
        break;
      default:
        // Do nothing.
    }
    return false;
  }

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isEnabled()) {
      long positionIncrement = getPositionIncrement();
      switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
          positionIncrement = -positionIncrement;
          // Fall through.
        case KeyEvent.KEYCODE_DPAD_RIGHT:
          if (scrubIncrementally(positionIncrement)) {
            removeCallbacks(stopScrubbingRunnable);
            postDelayed(stopScrubbingRunnable, STOP_SCRUBBING_TIMEOUT_MS);
            return true;
          }
          break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
          if (scrubbing) {
            stopScrubbing(/* canceled= */ false);
            return true;
          }
          break;
        default:
          // Do nothing.
      }
    }
    return super.onKeyDown(keyCode, event);
  }

  @Override
  protected void onFocusChanged(
      boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    if (scrubbing && !gainFocus) {
      stopScrubbing(/* canceled= */ false);
    }
  }

  @Override
  protected void drawableStateChanged() {
    super.drawableStateChanged();
    updateDrawableState();
  }

  @Override
  public void jumpDrawablesToCurrentState() {
    super.jumpDrawablesToCurrentState();
    if (scrubberDrawable != null) {
      scrubberDrawable.jumpToCurrentState();
    }
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    int height = heightMode == MeasureSpec.UNSPECIFIED ? touchTargetHeight
        : heightMode == MeasureSpec.EXACTLY ? heightSize : Math.min(touchTargetHeight, heightSize);
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), height);
    updateDrawableState();
  }

  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int width = right - left;
    int height = bottom - top;
    int barY = (height - touchTargetHeight) / 2;
    int seekLeft = getPaddingLeft();
    int seekRight = width - getPaddingRight();
    int progressY = barY + (touchTargetHeight - barHeight) / 2;
    seekBounds.set(seekLeft, barY, seekRight, barY + touchTargetHeight);
    progressBar.set(seekBounds.left + scrubberPadding, progressY,
        seekBounds.right - scrubberPadding, progressY + barHeight);
    update();
  }

  @Override
  public void onRtlPropertiesChanged(int layoutDirection) {
    if (scrubberDrawable != null && setDrawableLayoutDirection(scrubberDrawable, layoutDirection)) {
      invalidate();
    }
  }

  @Override
  public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
      event.getText().add(getProgressText());
    }
    event.setClassName(ACCESSIBILITY_CLASS_NAME);
  }

  @TargetApi(21)
  @Override
  public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(ACCESSIBILITY_CLASS_NAME);
    info.setContentDescription(getProgressText());
    if (duration <= 0) {
      return;
    }
    if (Util.SDK_INT >= 21) {
      info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD);
      info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD);
    } else {
      info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
      info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
    }
  }

  @Override
  public boolean performAccessibilityAction(int action, @Nullable Bundle args) {
    if (super.performAccessibilityAction(action, args)) {
      return true;
    }
    if (duration <= 0) {
      return false;
    }
    if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
      if (scrubIncrementally(-getPositionIncrement())) {
        stopScrubbing(/* canceled= */ false);
      }
    } else if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
      if (scrubIncrementally(getPositionIncrement())) {
        stopScrubbing(/* canceled= */ false);
      }
    } else {
      return false;
    }
    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
    return true;
  }

  // Internal methods.

  private void startScrubbing(long scrubPosition) {
    this.scrubPosition = scrubPosition;
    scrubbing = true;
    setPressed(true);
    ViewParent parent = getParent();
    if (parent != null) {
      parent.requestDisallowInterceptTouchEvent(true);
    }
    for (OnScrubListener listener : listeners) {
      listener.onScrubStart(this, scrubPosition);
    }
  }

  private void updateScrubbing(long scrubPosition) {
    if (this.scrubPosition == scrubPosition) {
      return;
    }
    this.scrubPosition = scrubPosition;
    for (OnScrubListener listener : listeners) {
      listener.onScrubMove(this, scrubPosition);
    }
  }

  private void stopScrubbing(boolean canceled) {
    removeCallbacks(stopScrubbingRunnable);
    scrubbing = false;
    setPressed(false);
    ViewParent parent = getParent();
    if (parent != null) {
      parent.requestDisallowInterceptTouchEvent(false);
    }
    invalidate();
    for (OnScrubListener listener : listeners) {
      listener.onScrubStop(this, scrubPosition, canceled);
    }
  }

  /**
   * Incrementally scrubs the position by {@code positionChange}.
   *
   * @param positionChange The change in the scrubber position, in milliseconds. May be negative.
   * @return Returns whether the scrubber position changed.
   */
  private boolean scrubIncrementally(long positionChange) {
    if (duration <= 0) {
      return false;
    }
    long previousPosition = scrubbing ? scrubPosition : position;
    long scrubPosition = Util.constrainValue(previousPosition + positionChange, 0, duration);
    if (scrubPosition == previousPosition) {
      return false;
    }
    if (!scrubbing) {
      startScrubbing(scrubPosition);
    } else {
      updateScrubbing(scrubPosition);
    }
    update();
    return true;
  }

  private void update() {
    bufferedBar.set(progressBar);
    scrubberBar.set(progressBar);
    long newScrubberTime = scrubbing ? scrubPosition : position;
    if (duration > 0) {
      int bufferedPixelWidth = (int) ((progressBar.width() * bufferedPosition) / duration);
      bufferedBar.right = Math.min(progressBar.left + bufferedPixelWidth, progressBar.right);
      int scrubberPixelPosition = (int) ((progressBar.width() * newScrubberTime) / duration);
      scrubberBar.right = Math.min(progressBar.left + scrubberPixelPosition, progressBar.right);
    } else {
      bufferedBar.right = progressBar.left;
      scrubberBar.right = progressBar.left;
    }
    invalidate(seekBounds);
  }

  private void positionScrubber(float xPosition) {
    scrubberBar.right = Util.constrainValue((int) xPosition, progressBar.left, progressBar.right);
  }

  private Point resolveRelativeTouchPosition(MotionEvent motionEvent) {
    getLocationOnScreen(locationOnScreen);
    touchPosition.set(
        ((int) motionEvent.getRawX()) - locationOnScreen[0],
        ((int) motionEvent.getRawY()) - locationOnScreen[1]);
    return touchPosition;
  }

  private long getScrubberPosition() {
    if (progressBar.width() <= 0 || duration == C.TIME_UNSET) {
      return 0;
    }
    return (scrubberBar.width() * duration) / progressBar.width();
  }

  private boolean isInSeekBar(float x, float y) {
    return seekBounds.contains((int) x, (int) y);
  }

  private void drawTimeBar(Canvas canvas) {
    int progressBarHeight = progressBar.height();
    int barTop = progressBar.centerY() - progressBarHeight / 2;
    int barBottom = barTop + progressBarHeight;
    if (duration <= 0) {
      canvas.drawRect(progressBar.left, barTop, progressBar.right, barBottom, unplayedPaint);
      return;
    }
    int bufferedLeft = bufferedBar.left;
    int bufferedRight = bufferedBar.right;
    int progressLeft = Math.max(Math.max(progressBar.left, bufferedRight), scrubberBar.right);
    if (progressLeft < progressBar.right) {
      canvas.drawRect(progressLeft, barTop, progressBar.right, barBottom, unplayedPaint);
    }
    bufferedLeft = Math.max(bufferedLeft, scrubberBar.right);
    if (bufferedRight > bufferedLeft) {
      canvas.drawRect(bufferedLeft, barTop, bufferedRight, barBottom, bufferedPaint);
    }
    if (scrubberBar.width() > 0) {
      canvas.drawRect(scrubberBar.left, barTop, scrubberBar.right, barBottom, playedPaint);
    }
    if (adGroupCount == 0) {
      return;
    }
    long[] adGroupTimesMs = Assertions.checkNotNull(this.adGroupTimesMs);
    boolean[] playedAdGroups = Assertions.checkNotNull(this.playedAdGroups);
    int adMarkerOffset = adMarkerWidth / 2;
    for (int i = 0; i < adGroupCount; i++) {
      long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration);
      int markerPositionOffset =
          (int) (progressBar.width() * adGroupTimeMs / duration) - adMarkerOffset;
      int markerLeft = progressBar.left + Math.min(progressBar.width() - adMarkerWidth,
          Math.max(0, markerPositionOffset));
      Paint paint = playedAdGroups[i] ? playedAdMarkerPaint : adMarkerPaint;
      canvas.drawRect(markerLeft, barTop, markerLeft + adMarkerWidth, barBottom, paint);
    }
  }

  private void drawPlayhead(Canvas canvas) {
    if (duration <= 0) {
      return;
    }
    int playheadX = Util.constrainValue(scrubberBar.right, scrubberBar.left, progressBar.right);
    int playheadY = scrubberBar.centerY();
    if (scrubberDrawable == null) {
      int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize
          : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize);
      int playheadRadius = scrubberSize / 2;
      canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint);
    } else {
      int scrubberDrawableWidth = scrubberDrawable.getIntrinsicWidth();
      int scrubberDrawableHeight = scrubberDrawable.getIntrinsicHeight();
      scrubberDrawable.setBounds(
          playheadX - scrubberDrawableWidth / 2,
          playheadY - scrubberDrawableHeight / 2,
          playheadX + scrubberDrawableWidth / 2,
          playheadY + scrubberDrawableHeight / 2);
      scrubberDrawable.draw(canvas);
    }
  }

  private void updateDrawableState() {
    if (scrubberDrawable != null && scrubberDrawable.isStateful()
        && scrubberDrawable.setState(getDrawableState())) {
      invalidate();
    }
  }

  private String getProgressText() {
    return Util.getStringForTime(formatBuilder, formatter, position);
  }

  private long getPositionIncrement() {
    return keyTimeIncrement == C.TIME_UNSET
        ? (duration == C.TIME_UNSET ? 0 : (duration / keyCountIncrement)) : keyTimeIncrement;
  }

  private boolean setDrawableLayoutDirection(Drawable drawable) {
    return Util.SDK_INT >= 23 && setDrawableLayoutDirection(drawable, getLayoutDirection());
  }

  private static boolean setDrawableLayoutDirection(Drawable drawable, int layoutDirection) {
    return Util.SDK_INT >= 23 && drawable.setLayoutDirection(layoutDirection);
  }

  public static int getDefaultScrubberColor(int playedColor) {
    return 0xFF000000 | playedColor;
  }

  public static int getDefaultUnplayedColor(int playedColor) {
    return 0x33000000 | (playedColor & 0x00FFFFFF);
  }

  public static int getDefaultBufferedColor(int playedColor) {
    return 0xCC000000 | (playedColor & 0x00FFFFFF);
  }

  public static int getDefaultPlayedAdMarkerColor(int adMarkerColor) {
    return 0x33000000 | (adMarkerColor & 0x00FFFFFF);
  }

  private static int dpToPx(float density, int dps) {
    return (int) (dps * density + 0.5f);
  }

  private static int pxToDp(float density, int px) {
    return (int) (px / density);
  }
}


text:
package org.phenoscape.orb;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import org.obo.datamodel.OBOClass;
import org.obo.datamodel.OBOSession;
import org.phenoscape.controller.PhenexController;
import org.phenoscape.scigraph.SciGraphResponse;
import org.phenoscape.util.ProvisionalTermUtil;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;
import org.w3c.dom.html.HTMLParamElement;
import org.xml.sax.SAXException;

public class ORBController {

	private final PhenexController controller;

	public ORBController(PhenexController controller) {
		this.controller = controller;
	}

	public void runORBTermRequest() {
		if (ProvisionalTermUtil.getAPIKey() == null || ProvisionalTermUtil.getUserID() == null) {
			JOptionPane.showMessageDialog(null,
					"Please first enter your ORB connection preferences using the ORB Connection Settings panel.",
					"ORB not configured", JOptionPane.ERROR_MESSAGE);
			return;
		} else {
			final ProvisionalTermRequestPanel panel = new ProvisionalTermRequestPanel(this.controller);
			panel.init();
			panel.setSize(400, 100);
			final int result = JOptionPane.showConfirmDialog(null, panel, "Submit new term request",
					JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
			if (result == JOptionPane.OK_OPTION) {
				final ORBTerm requestedTerm = panel.getTerm();
				try {
					this.requestTerm(requestedTerm);
				} catch (ClientProtocolException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IllegalStateException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (ParserConfigurationException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (SAXException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

	private OBOClass requestTerm(ORBTerm term) throws ClientProtocolException, IOException,
			ParserConfigurationException, IllegalStateException, SAXException {
		final OBOSession session = this.controller.getOntologyController().getOBOSession();
		final HttpPost post = new HttpPost(ProvisionalTermUtil.SERVICE);
		post.setHeader(new BasicHeader("Content-Type", "application/json"));
		post.setHeader(new BasicHeader("Authorization", "apikey token=" + ProvisionalTermUtil.getAPIKey()));
		post.setEntity(this.createPostEntity(term));
		final DefaultHttpClient client = new DefaultHttpClient();
		final HttpResponse response = new DefaultHttpClient().execute(post);
		client.getConnectionManager().shutdown();
		final JSONObject json = new JSONObject(IOUtils.toString(response.getEntity().getContent(), "utf-8"));
		final OBOClass newTerm = ProvisionalTermUtil.createClassForProvisionalTerm(json, session);
		session.addObject(newTerm);
		this.controller.getOntologyController().invalidateAllTermSets();
		this.controller.getOntologyCoordinator().getSelectionManager().selectTerm(this, newTerm, false);
		return newTerm;
	}

	private HttpEntity createPostEntity(ORBTerm term) throws UnsupportedEncodingException {
		final JSONObject json = new JSONObject();
		json.put("label", term.getLabel());
		json.put("definition", new JSONArray(Collections.singleton(term.getDefinition())));
		if (term.getParent() != null) {
			final String parentURI = ProvisionalTermUtil.toURI(term.getParent().getID());
			json.put("subclassOf", parentURI);
		}
		if (!term.getSynonyms().isEmpty()) {
			// FIXME this is not doing anything
			StringUtils.join(term.getSynonyms(), ",");
		}
		json.put("creator", ProvisionalTermUtil.getUserID());
		return new StringEntity(json.toString(), "utf-8");
	}

	@SuppressWarnings("unused")
	private Logger log() {
		return Logger.getLogger(this.getClass());
	}

}


text:
package com.subterranean_security.crimson.viewer.ui.screen.generator.ep;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;

import com.subterranean_security.crimson.core.util.ValidationUtil;
import com.subterranean_security.crimson.proto.core.Generator.NetworkTarget;
import com.subterranean_security.crimson.viewer.ui.common.components.labels.StatusLabel;
import com.subterranean_security.crimson.viewer.ui.common.panels.sl.epanel.EPanel;
import com.subterranean_security.crimson.viewer.ui.screen.generator.tabs.NTab;

public class AddNetworkTarget extends JPanel {

	private static final long serialVersionUID = 1L;
	private JTextField textField;
	private JTextField textField_1;

	private EPanel ep;
	private NTab parent;
	private StatusLabel lbl_status;

	public AddNetworkTarget(EPanel ep, NTab parent) {
		setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		this.ep = ep;
		this.parent = parent;
		init();
	}

	public void init() {
		setLayout(new BorderLayout(0, 0));

		JPanel panel_1 = new JPanel();
		add(panel_1);

		JPanel panel = new JPanel();
		panel_1.add(panel);
		panel.setPreferredSize(new Dimension(340, 60));
		panel.setLayout(null);
		panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

		textField = new JTextField();
		textField.setColumns(10);
		textField.setBounds(72, 9, 246, 17);
		panel.add(textField);

		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(72, 32, 47, 17);
		panel.add(textField_1);

		JLabel label = new JLabel("Port:");
		label.setFont(new Font("Dialog", Font.BOLD, 10));
		label.setBounds(12, 34, 53, 15);
		panel.add(label);

		JLabel label_1 = new JLabel("Server:");
		label_1.setFont(new Font("Dialog", Font.BOLD, 10));
		label_1.setBounds(12, 12, 53, 15);
		panel.add(label_1);

		lbl_status = new StatusLabel("Add new network target");
		add(lbl_status, BorderLayout.NORTH);

		JPanel panel_2 = new JPanel();
		add(panel_2, BorderLayout.SOUTH);

		JButton btnClose = new JButton("Close");
		btnClose.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ep.drop();
			}
		});
		btnClose.setFont(new Font("Dialog", Font.BOLD, 10));
		panel_2.add(btnClose);

		JButton btnAddTarget = new JButton("Add Target");
		btnAddTarget.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (verify()) {
					parent.table.add(NetworkTarget.newBuilder().setServer(textField.getText())
							.setPort(Integer.parseInt(textField_1.getText())).build());
					ep.drop();
				}
			}
		});
		btnAddTarget.setFont(new Font("Dialog", Font.BOLD, 10));
		panel_2.add(btnAddTarget);

	}

	private boolean verify() {
		if (!ValidationUtil.dns(textField.getText()) && !ValidationUtil.ipv4(textField.getText())) {
			lbl_status.setBad("Invalid server address");
			return false;
		}
		if (!ValidationUtil.port(textField_1.getText())) {
			lbl_status.setBad("Invalid port");
			return false;
		}

		return true;
	}

}


text:
require "volume_visualizer/data_size_string"
require "volume_visualizer/version"
require "volume_visualizer/cli"
require "volume_visualizer/zfs"

module VolumeVisualizer
  # Your code goes here...
end


text:
class ChangePriceColumnInProducts < ActiveRecord::Migration
  def change
  	change_column :products, :price, :decimal, :precision => 8, :scale => 2
  end
end


text:
import { Component, Input} from '@angular/core';
import { DocService } from '../doc.service';
import { PolarisComponent } from '../doc.data';
import { ComponentComponent } from '../utilities/component.component';

import { Types } from '../../library';

@Component({
    templateUrl: './breadcrumbs.component.html'
})
export class BreadcrumbsComponent extends ComponentComponent {

    protected componentPath: string = 'breadcrumbs/breadcrumbs.component';

    label:string = 'Hello world';
    id:string = 'SampleID123';
    helpText:string = '';
    error:any = '';

    breadcrumbs: Types.AngularComplexAction[] = [{content: "Root Page", url: "#"}];

    constructor(protected service: DocService) {
        super(service);
    }

    public popAction() {
        if (this.breadcrumbs.length > 1) {
            this.breadcrumbs.pop();
        }
    }

    public pushLogAction() {
        this.breadcrumbs.push({
            content: "Log to console " + (this.breadcrumbs.length + 1),
            onAction: () => {this.eventLog(null, 'Crumb click');}
        });
    }

    public pushUrl() {
        this.breadcrumbs.push({
            content: "URL link " + (this.breadcrumbs.length + 1),
            url: "doc"
        });
    }

    public pushRouterLink() {
        this.breadcrumbs.push({
            content: "Router link " + (this.breadcrumbs.length + 1),
            routerLink: "/doc"
        });
    }

    public get code(): string {
        const status = this.nullableAttr('status');
        const progress = this.nullableAttr('progress');

        let breadcrumbs: string = this.breadcrumbs.map((crumb) => {
            if (crumb.onAction) {
                return this.indent(`{'content': '${crumb.content}, 'onAction': () => eventLog(null, 'Crumb click') }'`, 2);
            } else {
                return this.indent(JSON.stringify(crumb).replace(/"/g, "'"), 2);
            }
        }).join(',');

return `<plrsBreadcrumbs
    [breadcrumbs]="[${breadcrumbs}
    ]">
</plrsBreadcrumbs>`;
    }

}


text:
import {default as EventSystem} from "./EventSystem";

import {expect} from "chai";

describe("EventSystem", (): any => {

    function sendEvents(name: string): void {
        EventSystem.fireEvent(name, 1);
        EventSystem.fireEvent(name, 2);
        EventSystem.fireEvent(name, 3);
    }

    function receiveEvents(name: string, done: Function): void {
        let receivedEvents: number = 0;

        EventSystem.registerEventListener(name, (obj: number) => {
            receivedEvents++;

            expect(obj).to.equal(receivedEvents);

            if (receivedEvents === 3) {
                done();
            }
        });
    }

    it("should send events to listener", (done: Function) => {
        receiveEvents("test1", done);
        sendEvents("test1");
    });

    it("should replay events to late listener", (done: Function) => {
        sendEvents("test2");
        receiveEvents("test2", done);
    });

    it("should limit number of events to replay", (done: Function) => {
        for (let i: number = 1; i <= 101; i++) {
            EventSystem.fireEvent("test3", i);
        }

        let receivedEvents: number = 1;
        EventSystem.registerEventListener("test3", (obj: number) => {
            receivedEvents++;
            expect(obj).to.equal(receivedEvents);
            if (receivedEvents === 100) {
                done();
            }
        });
    });

    it("should listen to event only once when 'once' option is set", (done: Function) => {
        EventSystem.registerEventListener("test4", () => {
            done(); // if this is called multiple times than Jasmine throws error
        }, { once: true });

        EventSystem.fireEvent("test4");
        EventSystem.fireEvent("test4");
    });

    it("should not replay events when 'replay' option is not set", (done: Function) => {
        EventSystem.fireEvent("test5");
        EventSystem.registerEventListener("test5", () => {
            done(); // if this is called multiple times than Jasmine throws error
        }, { replay: false });

        EventSystem.fireEvent("test5");
    });

    it("should send event with multiple arguments", (done: Function) => {
        EventSystem.fireEvent("test6", "hello", "world");
        EventSystem.registerEventListener("test6", (hello: string, world: string) => {
            expect(hello + " " + world).to.equal("hello world");
            done();
        }, { replay: true, once: true });
    });

    it("should execute all listener also if some throws an exception", (done: Function) => {
        let evilExecutions: number = 0;
        EventSystem.registerEventListener("test7", () => {
            evilExecutions++;
            throw new Error("Test 7 EVIL");
        });
        EventSystem.registerEventListener("test7", () => {
            evilExecutions++;
            throw new Error("also EVIL");
        });
        EventSystem.registerEventListener("test7", () => {
            if (evilExecutions === 2) {
                done();
            }
        });
        EventSystem.fireEvent("test7");
    });

});


text:
@interface UIApplication (Tool)

@end

@interface UIApplication (ApplicationSize)

- (NSString *)applicationSize;

@end

@interface UIApplication (KeyboardFrame)

- (CGRect)keyboardFrame;

@end


text:
#include "zlib.h"

#include <iostream>
#include <cstring>
#include <cctype>

#define CHUNK_SIZE 16384

int main()
{
    std::cout << "Zlib version: " << zlibVersion() << std::endl;

    char in_buffer[] = "Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello";
    char out_buffer[CHUNK_SIZE];

    z_stream stream;
    stream.zalloc = Z_NULL;
    stream.zfree = Z_NULL;
    stream.opaque = Z_NULL;
    int compressionLevel = Z_DEFAULT_COMPRESSION;
    if (Z_OK != deflateInit(&stream, compressionLevel))
    {
        return -1;
    }

    const size_t originalLength = strlen(in_buffer);
    stream.avail_in = static_cast<int>(originalLength);
    stream.next_in = (Bytef*)in_buffer;

    std::cout << "Original size: " << originalLength << std::endl;

    stream.avail_out = CHUNK_SIZE;
    stream.next_out = (Bytef*)out_buffer;

    // there are multiple 'success codes' here
    if (Z_STREAM_ERROR == deflate(&stream, Z_FINISH))
    {
        return -1;
    }

    int compressedLength = CHUNK_SIZE - stream.avail_out;
    std::cout << "Compressed size: " << compressedLength << " - " << 100 * static_cast<float>(compressedLength)/originalLength <<  "% of original size" << std::endl;

    for (int i = 0; i < compressedLength; ++i)
    {
        char c = out_buffer[i];
        std::cout << i << " : " << static_cast<int>(c);
        if (std::isalnum(c))
        {
            std::cout << " (" << c << ")";
        }
        std::cout << std::endl;
    }

    if (stream.avail_in > 0)
    {
        // there is more data
        return -1;
    }

    if (Z_OK != deflateEnd(&stream))
    {
        return -1;
    }

    return 0;
}