/** * Compiles a {@link MethodDescriptor} for the given raw descriptor. * * @param descriptor The raw method descriptor * @return The descriptor */ public static MethodDescriptor of(final String descriptor) { return new MethodDescriptorReader(descriptor).read(); }
/** * Reads the next {@link MethodDescriptor} from source. * * @return The type * @throws IllegalStateException If the descriptor is invalid */ public MethodDescriptor read() { final List<FieldType> params = new ArrayList<>(); if (this.peek() != '(') throw new IllegalStateException("Invalid descriptor provided!"); this.advance(); while (this.hasNext() && this.peek() != ')') { params.add(this.readFieldType()); } if (this.peek() != ')') throw new IllegalStateException("Invalid descriptor provided!"); this.advance(); return new MethodDescriptor(params, this.readType()); }