# Class WeightedAshwoodEntitySorter

java.lang.Object
org.apache.cayenne.ashwood.AshwoodEntitySorter
org.apache.cayenne.ashwood.WeightedAshwoodEntitySorter

All Implemented Interfaces:
  `EntitySorter`

public class WeightedAshwoodEntitySorter extends AshwoodEntitySorter
EntitySorter that takes into account entity "weights", and otherwise delegating to another (topological) sorter.

Since:
  3.1, since 4.0 moved to cayenne-server from cayenne-lifecycle

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Map<DbEntity,Integer>`
  `entityWeights`

  ### Fields inherited from class AshwoodEntitySorter

  `components, dbEntityComparator, entityResolver, objEntityComparator, reflexiveDbEntities`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WeightedAshwoodEntitySorter(EntityResolver entityResolver)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addWeightForEntity(ObjEntity entity)`
  `protected Comparator<DbEntity>`
  `getDbEntityComparator(boolean dependantFirst)`
  `protected Comparator<ObjEntity>`
  `getObjEntityComparator(boolean dependantFirst)`
  `void`
  `reindex()`
  Rebuilds the internal index off the current state of the sorter's EntityResolver.

  ### Methods inherited from class AshwoodEntitySorter

  `buildDigraph, findReflexiveMaster, getDbEntityComparator, getObjEntityComparator, getReflexiveRelationshipsNames, isReflexive, sortDbEntities, sortObjectsForEntity, sortObjectsForEntity, sortObjEntities, topologicalSort`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### entityWeights

    protected volatile Map<DbEntity,Integer> entityWeights

- ## Constructor Details

  - ### WeightedAshwoodEntitySorter

    public WeightedAshwoodEntitySorter(EntityResolver entityResolver)

- ## Method Details

  - ### reindex

    public void reindex()
    Description copied from interface: `EntitySorter`
    Rebuilds the internal index off the current state of the sorter's EntityResolver. Called when the set of entities changes.
    Specified by:
      `reindex` in interface `EntitySorter`
    Overrides:
      `reindex` in class `AshwoodEntitySorter`

  - ### addWeightForEntity

    protected void addWeightForEntity(ObjEntity entity)

  - ### getDbEntityComparator

    protected Comparator<DbEntity> getDbEntityComparator(boolean dependantFirst)
    Overrides:
      `getDbEntityComparator` in class `AshwoodEntitySorter`

  - ### getObjEntityComparator

    protected Comparator<ObjEntity> getObjEntityComparator(boolean dependantFirst)
    Overrides:
      `getObjEntityComparator` in class `AshwoodEntitySorter`