# HierarchyBuilder (ARX API Documentation)

org.deidentifier.arx.aggregates

## Class HierarchyBuilder<T>

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

- Type Parameters:
    `T` -
  All Implemented Interfaces:
    java.io.Serializable
  Direct Known Subclasses:
    HierarchyBuilderGroupingBased, HierarchyBuilderRedactionBased

      public abstract class HierarchyBuilder<T>
      extends java.lang.Object
      implements java.io.Serializable

  Base class for hierarchy builders. Hierarchies can be built in two ways:
  1. Call prepare(data), which returns some metadata and preserves a state, and then calling build(), or
  2. Call build(data)
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `HierarchyBuilder.Type` The three types of builders.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract AttributeType.Hierarchy` | `build()` Creates a new hierarchy, based on the predefined specification.
    `abstract AttributeType.Hierarchy` | `build(java.lang.String[] data)` Creates a new hierarchy, based on the predefined specification.
    `static <T> HierarchyBuilder<T>` | `create(java.io.File file)` Loads a builder from a file.
    `static <T> HierarchyBuilder<T>` | `create(java.lang.String file)` Loads a builder from a file.
    `HierarchyBuilder.Type` | `getType()` Returns the type of builder.
    `abstract int[]` | `prepare(java.lang.String[] data)` Prepares the builder.
    `void` | `save(java.io.File file)` Saves the specification of this builder to the given file.
    `void` | `save(java.lang.String file)` Saves the specification of this builder to the given file.

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

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

- - ### Method Detail

    - #### create

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

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

    - #### create

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

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

    - #### build

          public abstract AttributeType.Hierarchy build()

      Creates a new hierarchy, based on the predefined specification.
      Returns:

    - #### build

          public abstract AttributeType.Hierarchy build(java.lang.String[] data)

      Creates a new hierarchy, based on the predefined specification.
      Parameters:
        `data` -
      Returns:

    - #### getType

          public HierarchyBuilder.Type getType()

      Returns the type of builder.
      Returns:

    - #### prepare

          public abstract int[] prepare(java.lang.String[] data)

      Prepares the builder. Returns a list of the number of equivalence classes per level
      Parameters:
        `data` -
      Returns:

    - #### save

          public void save(java.io.File file)
                    throws java.io.IOException

      Saves the specification of this builder to the given file.
      Parameters:
        `file` -
      Throws:
        `java.io.IOException`

    - #### save

          public void save(java.lang.String file)
                    throws java.io.IOException

      Saves the specification of this builder to the given file.
      Parameters:
        `file` -
      Throws:
        `java.io.IOException`