/** * Gets the {@link PrimitiveType} for the given type key. * * @param key The type key * @return The primitive type * @throws IllegalStateException If the descriptor is invalid */ static PrimitiveType getFromKey(char key) { if (key == 'V') { return VoidType.INSTANCE; } if (BaseType.isValidBase(key)) { return BaseType.getFromKey(key); } throw new IllegalStateException("Invalid primitive type: " + key); }
/** * Reads the next {@link PrimitiveType} from source. * * @return The type * @throws IllegalStateException If the descriptor is invalid */ public PrimitiveType readPrimitiveType() { // Void Type if (this.peek() == 'V') { this.advance(); return VoidType.INSTANCE; } // Base Type if (BaseType.isValidBase(this.peek())) { return this.readBaseType(); } throw new IllegalStateException("Invalid descriptor provided!"); }
/** * Reads the next {@link FieldType} from source. * * @return The type * @throws IllegalStateException If the descriptor is invalid */ public FieldType readFieldType() { // Array Type if (this.peek() == '[') { return this.readArrayType(); } // Base Type if (BaseType.isValidBase(this.peek())) { return this.readBaseType(); } // Object Type if (this.peek() == 'L') { return this.readObjectType(); } throw new IllegalStateException("Invalid descriptor provided!"); }