org.apache.lucene.util.automaton

## Class State

- java.lang.Object
- - org.apache.lucene.util.automaton.State

All Implemented Interfaces:
  Comparable<State>

    public class State
    extends Object
    implements Comparable<State>

`Automaton` state.

WARNING: This API is experimental and might change in incompatible ways in the next release.

### Field Summary

Fields
`int` `numTransitions`
`Transition[]` `transitionsArray`

### Constructor Summary

Constructors
Constructor and Description
`State()` Constructs a new state.

### Method Summary

Methods
`void` `addTransition(Transition t)` Adds an outgoing transition.
`int` `compareTo(State s)` Compares this object with the specified object for order.
`int` `getNumber()` Return this state's number.
`Iterable<Transition>` `getTransitions()` Returns the set of outgoing transitions.
`int` `hashCode()`
`boolean` `isAccept()` Returns acceptance status.
`int` `numTransitions()`
`void` `reduce()` Reduces this state.
`void` `setAccept(boolean accept)` Sets acceptance for this state.
`void` `setTransitions(Transition[] transitions)`
`void` `sortTransitions(Comparator<Transition> comparator)` Sorts transitions array in-place.
`State` `step(int c)` Performs lookup in transitions, assuming determinism.
`void` `step(int c, Collection<State> dest)` Performs lookup in transitions, allowing nondeterminism.
`String` `toString()` Returns string describing this state.
`void` `trimTransitionsArray()` Downsizes transitionArray to numTransitions

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

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

### Field Detail

#### transitionsArray

    public Transition[] transitionsArray

#### numTransitions

    public int numTransitions

### Constructor Detail

#### State

    public State()

Constructs a new state. Initially, the new state is a reject state.

### Method Detail

#### getTransitions

    public Iterable<Transition> getTransitions()

Returns the set of outgoing transitions. Subsequent changes are reflected in the automaton.

Returns:
  transition set

#### numTransitions

    public int numTransitions()

#### setTransitions

    public void setTransitions(Transition[] transitions)

#### addTransition

    public void addTransition(Transition t)

Adds an outgoing transition.

Parameters:
  `t` - transition

#### setAccept

    public void setAccept(boolean accept)

Sets acceptance for this state.

Parameters:
  `accept` - if true, this state is an accept state

#### isAccept

    public boolean isAccept()

Returns acceptance status.

Returns:
  true is this is an accept state

#### step

    public State step(int c)

Performs lookup in transitions, assuming determinism.

Parameters:
  `c` - codepoint to look up
Returns:
  destination state, null if no matching outgoing transition
See Also:
  `step(int, Collection)`

#### step

    public void step(int c,
            Collection<State> dest)

Performs lookup in transitions, allowing nondeterminism.

Parameters:
  `c` - codepoint to look up
  `dest` - collection where destination states are stored
See Also:
  `step(int)`

#### trimTransitionsArray

    public void trimTransitionsArray()

Downsizes transitionArray to numTransitions

#### reduce

    public void reduce()

Reduces this state. A state is "reduced" by combining overlapping and adjacent edge intervals with same destination.

#### sortTransitions

    public void sortTransitions(Comparator<Transition> comparator)

Sorts transitions array in-place.

#### getNumber

    public int getNumber()

Return this state's number.

Expert: Will be useless unless `Automaton.getNumberedStates()` has been called first to number the states.

Returns:
  the number

#### toString

    public String toString()

Returns string describing this state. Normally invoked via `Automaton.toString()`.

Overrides:
  `toString` in class `Object`

#### compareTo

    public int compareTo(State s)

Compares this object with the specified object for order. States are ordered by the time of construction.

Specified by:
  `compareTo` in interface `Comparable<State>`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`