# HierarchyBuilderOrderBased (ARX Developer Documentation)

org.deidentifier.arx.aggregates

## Class HierarchyBuilderOrderBased<T>

- java.lang.Object
- - org.deidentifier.arx.aggregates.HierarchyBuilder<T>
  - - org.deidentifier.arx.aggregates.HierarchyBuilderGroupingBased<T>
    - - org.deidentifier.arx.aggregates.HierarchyBuilderOrderBased<T>

- Type Parameters:
    `T` -
  All Implemented Interfaces:
    java.io.Serializable

      public class HierarchyBuilderOrderBased<T>
      extends HierarchyBuilderGroupingBased<T>

  This class enables building hierarchies for categorical and non-categorical values by ordering the data items and merging into groups with predefined sizes.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `HierarchyBuilderOrderBased.CloseElements<T>` Internal helper class
    `static class` | `HierarchyBuilderOrderBased.SerializableComparator<T>` A serializable comparator.

    - ### Nested classes/interfaces inherited from class org.deidentifier.arx.aggregates.HierarchyBuilderGroupingBased

      `HierarchyBuilderGroupingBased.AbstractGroup, HierarchyBuilderGroupingBased.Group<U>, HierarchyBuilderGroupingBased.Level<U>`

    - ### Nested classes/interfaces inherited from class org.deidentifier.arx.aggregates.HierarchyBuilder

      `HierarchyBuilder.Type`

  - ### Field Summary

    - ### Fields inherited from class org.deidentifier.arx.aggregates.HierarchyBuilderGroupingBased

      `function`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> HierarchyBuilderOrderBased<T>` | `create(DataType<T> type, boolean order)` Creates a new instance.
    `static <T> HierarchyBuilderOrderBased<T>` | `create(DataType<T> type, java.util.Comparator<T> comparator)` Creates a new instance.
    `static <T> HierarchyBuilderOrderBased<T>` | `create(DataType<T> type, java.lang.String[] order)` Creates a new instance.
    `static <T> HierarchyBuilderOrderBased<T>` | `create(java.io.File file)` Loads a builder specification from the given file.
    `static <T> HierarchyBuilderOrderBased<T>` | `create(java.lang.String file)` Loads a builder specification from the given file.
    `java.util.Comparator<java.lang.String>` | `getComparator()` Returns the comparator.
    `protected HierarchyBuilderGroupingBased.AbstractGroup[][]` | `prepareGroups()` Tells the implementing class to prepare the generalization process.

    - ### Methods inherited from class org.deidentifier.arx.aggregates.HierarchyBuilderGroupingBased

      `build, build, getData, getDataType, getDefaultFunction, getLevel, getLevels, getPreparedGroups, isValid, prepare, setAggregateFunction, setData, setLevels, setPrepared`

    - ### Methods inherited from class org.deidentifier.arx.aggregates.HierarchyBuilder

      `getType, save, save`

    - ### Methods inherited from class java.lang.Object

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

- - ### Method Detail

    - #### create

          public static <T> HierarchyBuilderOrderBased<T> create(DataType<T> type,
                                                 boolean order)

      Creates a new instance. Either preserves the given order, or sorts the items according to the order induced by the given data type
      Type Parameters:
        `T` -
      Parameters:
        `type` - The data type is also used for ordering data items
        `order` - Should the items be sorted according to the order induced by the data type
      Returns:

    - #### create

          public static <T> HierarchyBuilderOrderBased<T> create(DataType<T> type,
                                                 java.util.Comparator<T> comparator)

      Creates a new instance. Uses the comparator for ordering data items
      Type Parameters:
        `T` -
      Parameters:
        `type` - The data type
        `comparator` - Use this comparator for ordering data items
      Returns:

    - #### create

          public static <T> HierarchyBuilderOrderBased<T> create(DataType<T> type,
                                                 java.lang.String[] order)

      Creates a new instance. Uses the defined order for data items
      Type Parameters:
        `T` -
      Parameters:
        `type` - The data type
        `order` - Use this for ordering data items
      Returns:

    - #### create

          public static <T> HierarchyBuilderOrderBased<T> create(java.io.File file)
                                                      throws java.io.IOException

      Loads a builder specification from the given file.
      Type Parameters:
        `T` -
      Parameters:
        `file` -
      Returns:
      Throws:
        `java.io.IOException`

    - #### create

          public static <T> HierarchyBuilderOrderBased<T> create(java.lang.String file)
                                                      throws java.io.IOException

      Loads a builder specification from the given file.
      Type Parameters:
        `T` -
      Parameters:
        `file` -
      Returns:
      Throws:
        `java.io.IOException`

    - #### getComparator

          public java.util.Comparator<java.lang.String> getComparator()

      Returns the comparator.
      Returns:

    - #### prepareGroups

          protected HierarchyBuilderGroupingBased.AbstractGroup[][] prepareGroups()

      Description copied from class: `HierarchyBuilderGroupingBased`
      Tells the implementing class to prepare the generalization process.
      Specified by:
        `prepareGroups` in class `HierarchyBuilderGroupingBased<T>`
      Returns: