@Test(expected = IllegalStateException.class) public void testThrowOnWrongCastStruct() throws IOException { StackItem rawItem = OBJECT_MAPPER.readValue(BYTESTRING_JSON, StackItem.class); rawItem.asStruct(); }
@JsonIgnore public StructStackItem asStruct() { if (this instanceof StructStackItem) { return (StructStackItem) this; } throw new IllegalStateException("This stack item is not of type " + StackItemType.STRUCT.jsonValue() + " but of " + this.type.jsonValue()); }
StackItem { @JsonIgnore public StructStackItem asStruct() { if (this instanceof StructStackItem) { return (StructStackItem) this; } throw new IllegalStateException("This stack item is not of type " + StackItemType.STRUCT.jsonValue() + " but of " + this.type.jsonValue()); } }
StackItem { @JsonIgnore public StructStackItem asStruct() { if (this instanceof StructStackItem) { return (StructStackItem) this; } throw new IllegalStateException("This stack item is not of type " + StackItemType.STRUCT.jsonValue() + " but of " + this.type.jsonValue()); } StackItem();  StackItem(StackItemType type); }
StackItem { @JsonIgnore public StructStackItem asStruct() { if (this instanceof StructStackItem) { return (StructStackItem) this; } throw new IllegalStateException("This stack item is not of type " + StackItemType.STRUCT.jsonValue() + " but of " + this.type.jsonValue()); } StackItem();  StackItem(StackItemType type); StackItemType getType(); @JsonIgnore ByteStringStackItem asByteString(); @JsonIgnore PointerStackItem asPointer(); @JsonIgnore BooleanStackItem asBoolean(); @JsonIgnore IntegerStackItem asInteger(); @JsonIgnore BufferStackItem asBuffer(); @JsonIgnore ArrayStackItem asArray(); @JsonIgnore MapStackItem asMap(); @JsonIgnore StructStackItem asStruct(); @JsonIgnore Object asAny(); @JsonIgnore Object asInteropInterface(); }
StackItem { @JsonIgnore public StructStackItem asStruct() { if (this instanceof StructStackItem) { return (StructStackItem) this; } throw new IllegalStateException("This stack item is not of type " + StackItemType.STRUCT.jsonValue() + " but of " + this.type.jsonValue()); } StackItem();  StackItem(StackItemType type); StackItemType getType(); @JsonIgnore ByteStringStackItem asByteString(); @JsonIgnore PointerStackItem asPointer(); @JsonIgnore BooleanStackItem asBoolean(); @JsonIgnore IntegerStackItem asInteger(); @JsonIgnore BufferStackItem asBuffer(); @JsonIgnore ArrayStackItem asArray(); @JsonIgnore MapStackItem asMap(); @JsonIgnore StructStackItem asStruct(); @JsonIgnore Object asAny(); @JsonIgnore Object asInteropInterface();  }