org.apache.xmlgraphics.image.loader.util

## Class Penalty

- java.lang.Object
- - org.apache.xmlgraphics.image.loader.util.Penalty

-     public final class Penalty
      extends java.lang.Object

  Immutable class representing a penalty value. It's valid value range is that of an `Integer`, but giving `Integer.MAX_VALUE` a special meaning: it means infinite penalty, i.e. a candidate with this penalty will be excluded from any choice.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Penalty` | `INFINITE_PENALTY`
    `static Penalty` | `ZERO_PENALTY`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Penalty` | `add(int value)` Adds a penalty to this one and returns the combined penalty.
    `Penalty` | `add(Penalty value)` Adds a penalty to this one and returns the combined penalty.
    `int` | `getValue()` Returns the penalty value.
    `boolean` | `isInfinitePenalty()` Indicates whether this is an infinite penalty, meaning that a solution with this penalty is effectively ineligible.
    `static Penalty` | `toPenalty(int value)` Turns a penalty value into a penaly object.
    `java.lang.String` | `toString()`
    `static int` | `truncate(long penalty)` Truncates the long penalty value to an integer without sign side-effects.

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

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

- - ### Field Detail

    - #### ZERO_PENALTY

          public static final Penalty ZERO_PENALTY

    - #### INFINITE_PENALTY

          public static final Penalty INFINITE_PENALTY

  - ### Method Detail

    - #### toPenalty

          public static Penalty toPenalty(int value)

      Turns a penalty value into a penaly object.
      Parameters:
        `value` - the penalty value
      Returns:
        the penalty object

    - #### add

          public Penalty add(Penalty value)

      Adds a penalty to this one and returns the combined penalty.
      Parameters:
        `value` - the penalty value to add
      Returns:
        the resulting penalty

    - #### add

          public Penalty add(int value)

      Adds a penalty to this one and returns the combined penalty.
      Parameters:
        `value` - the penalty value to add
      Returns:
        the resulting penalty

    - #### getValue

          public int getValue()

      Returns the penalty value.
      Returns:
        the penalty value

    - #### isInfinitePenalty

          public boolean isInfinitePenalty()

      Indicates whether this is an infinite penalty, meaning that a solution with this penalty is effectively ineligible.
      Returns:
        true if this is an infinite penalty

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### truncate

          public static int truncate(long penalty)

      Truncates the long penalty value to an integer without sign side-effects.
      Parameters:
        `penalty` - the penalty value as a long
      Returns:
        the penalty value as an int

Copyright 1999-2021 The Apache Software Foundation. All Rights Reserved.