package com.sksamuel.elastic4s.searches.aggs

trait AbstractAggregation {
  type T <: AbstractAggregation
  def name: String
  def metadata: Map[String, AnyRef]
  def metadata(map: Map[String, AnyRef]): T
}

trait AggregationDefinition extends AbstractAggregation {

  def subaggs: Seq[AbstractAggregation]

  def subagg(agg: AbstractAggregation): T = subaggs(agg, subaggs: _*)
  def subaggs(first: AbstractAggregation, rest: AbstractAggregation*): T = subaggs(first +: rest)
  def subaggs(aggs: Iterable[AbstractAggregation]): T = subAggregations(aggs)

  def subAggregation(agg: AbstractAggregation): T = subAggregations(agg, subaggs: _*)
  def subAggregations(first: AbstractAggregation, rest: AbstractAggregation*): T = subAggregations(first +: rest)
  def subAggregations(aggs: Iterable[AbstractAggregation]): T
}

package com.sksamuel.elastic4s.searches.aggs

trait AbstractAggregation {
  type T <: AbstractAggregation
  def name: String
  def metadata: Map[String, AnyRef]
  def metadata(map: Map[String, AnyRef]): T
}

trait AggregationDefinition extends AbstractAggregation {

  def subaggs: Seq[AbstractAggregation]

  def addSubagg(agg: AbstractAggregation): T = subaggs(subaggs :+ agg)
  def subaggs(first: AbstractAggregation, rest: AbstractAggregation*): T = subaggs(first +: rest)
  def subaggs(aggs: Iterable[AbstractAggregation]): T = subAggregations(aggs)

  def addSubAggregation(agg: AbstractAggregation): T = subAggregations(subaggs :+ agg)
  def subAggregations(first: AbstractAggregation, rest: AbstractAggregation*): T = subAggregations(first +: rest)
  def subAggregations(aggs: Iterable[AbstractAggregation]): T
}

Add 'add' prefix to singular method names to reflect their behavior
Add 'add' prefix to singular method names to reflect their behavior
