<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@contract-case/case-definition-dsl](./case-definition-dsl.md) &gt; [states](./case-definition-dsl.states.md) &gt; [AnyState](./case-definition-dsl.states.anystate.md)

## states.AnyState class

The base class for all ContractCase State Descriptors. You shouldn't need to extend this.

You don't need to read the documentation for this class unless you are working on a wrapper for ContractCase.

**Signature:**

```typescript
export declare abstract class AnyState
```

## Constructors

<table><thead><tr><th>

Constructor

</th><th>

Modifiers

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

[(constructor)(stateType, stateName)](./case-definition-dsl.states.anystate._constructor_.md)

</td><td>

</td><td>

The base class for all ContractCase State Descriptors. You shouldn't need to extend this.

You don't need to read the documentation for this class unless you are working on a wrapper for ContractCase.

</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

[stateName](./case-definition-dsl.states.anystate.statename.md)

</td><td>

`readonly`

</td><td>

string

</td><td>

The name of this state, used to determine which state handler to run

</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method

</th><th>

Modifiers

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

[stringify()](./case-definition-dsl.states.anystate.stringify.md)

</td><td>

</td><td>

You shouldn't need to override this method. You don't need to call this method, unless working on a wrapper for ContractCase.

This method returns the entire state descriptor as a JSON string, as a convenience so that wrapper libraries don't need to figure out how to walk a tree of example objects.

</td></tr>
<tr><td>

[toJSON()](./case-definition-dsl.states.anystate.tojson.md)

</td><td>

</td><td>

You shouldn't need to override or call this method.

It exists because the ContractCase matcher format is not legal in all languages that ContractCase supports.

It isn't called by any implementation directly, it's used on the javascript side by `JSON.stringify()`<!-- -->.

Calling it from a wrapper library will return unhelpful results, as JSii can't map all objects that it returns.

WARNING: Do not return a string from this method. You must instead return an object that can be serialised to JSON following the matcher format described in \[Extending ContractCase\](https://case.contract-testing.io/docs/reference/plugin-framework).

</td></tr>
</tbody></table>
