/** * Returns the first valid implementation as a StaticField or throws a * RuntimeException if there is none. * * @param <T> Java class stored in the field * @return a {@link StaticField} with a valid implementation * @throws IllegalStateException if the method is not static * @throws RuntimeException if no implementation was found */ public <T> StaticField<T> buildStatic() { return this.<T>build().asStatic(); }
IndexedRecordReader(List<ValueReader<?>> readers, Class<R> recordClass, Schema schema) { super(readers); this.recordClass = recordClass; this.ctor = DynConstructors.builder(IndexedRecord.class) .hiddenImpl(recordClass, Schema.class) .hiddenImpl(recordClass) .build(); this.schema = schema; }
/** * Returns the first valid implementation as a StaticMethod or throws a * RuntimeException if there is none. * * @return a {@link StaticMethod} with a valid implementation * @throws IllegalStateException if the method is not static * @throws RuntimeException if no implementation was found */ public StaticMethod buildStatic() { return build().asStatic(); }
/** * Returns the first valid implementation as a BoundMethod or throws a * NoSuchMethodException if there is none. * * @param receiver an Object to receive the method invocation * @return a {@link BoundMethod} with a valid implementation and receiver * @throws IllegalStateException if the method is static * @throws IllegalArgumentException if the receiver's class is incompatible * @throws NoSuchMethodException if no implementation was found */ public BoundMethod buildChecked(Object receiver) throws NoSuchMethodException { return buildChecked().bind(receiver); }
/** * Returns the first valid implementation as a BoundMethod or throws a * RuntimeError if there is none. * * @param receiver an Object to receive the method invocation * @return a {@link BoundMethod} with a valid implementation and receiver * @throws IllegalStateException if the method is static * @throws IllegalArgumentException if the receiver's class is incompatible * @throws RuntimeException if no implementation was found */ public BoundMethod build(Object receiver) { return build().bind(receiver); }
/** * Returns the first valid implementation as a StaticField or throws a * NoSuchFieldException if there is none. * * @param <T> Java class stored in the field * @return a {@link StaticField} with a valid implementation * @throws IllegalStateException if the method is not static * @throws NoSuchFieldException if no implementation was found */ public <T> StaticField<T> buildStaticChecked() throws NoSuchFieldException { return this.<T>buildChecked().asStatic(); }
/** * Returns the first valid implementation as a StaticMethod or throws a * NoSuchMethodException if there is none. * * @return a {@link StaticMethod} with a valid implementation * @throws IllegalStateException if the method is not static * @throws NoSuchMethodException if no implementation was found */ public StaticMethod buildStaticChecked() throws NoSuchMethodException { return buildChecked().asStatic(); }
/** * Returns the first valid implementation as a BoundMethod or throws a * RuntimeException if there is none. * * @param target an Object on which to get and set the field * @param <T> Java class stored in the field * @return a {@link BoundField} with a valid implementation and target * @throws IllegalStateException if the method is static * @throws IllegalArgumentException if the receiver's class is incompatible * @throws RuntimeException if no implementation was found */ public <T> BoundField<T> build(Object target) { return this.<T>build().bind(target); }
/** * Returns the first valid implementation as a BoundMethod or throws a * NoSuchMethodException if there is none. * * @param target an Object on which to get and set the field * @param <T> Java class stored in the field * @return a {@link BoundField} with a valid implementation and target * @throws IllegalStateException if the method is static * @throws IllegalArgumentException if the receiver's class is incompatible * @throws NoSuchFieldException if no implementation was found */ public <T> BoundField<T> buildChecked(Object target) throws NoSuchFieldException { return this.<T>buildChecked().bind(target); }
/** * Returns this method as a StaticMethod. * * @return a {@link StaticMethod} for this method * @throws IllegalStateException if the method is not static */ public StaticMethod asStatic() { Preconditions.checkState(isStatic(), "Method is not static"); return new StaticMethod(this); }
/** * Returns this field as a StaticField. * * @return a {@link StaticField} for this field * @throws IllegalStateException if the method is not static */ public StaticField<T> asStatic() { Preconditions.checkState(isStatic(), "Field " + name + " is not static"); return new StaticField<>(this); }
public void set(T value) { field.set(null, value); } }
/** * Constructs a new builder for calling methods dynamically. * * @param methodName name of the method the builder will locate * @return a Builder for finding a method */ public static Builder builder(String methodName) { return new Builder(methodName); }
public static Builder builder() { return new Builder(); }
public T get() { return field.get(target); }
public static Builder builder() { return new Builder(); }
@Override public BoundMethod bind(Object receiver) { return new BoundMethod(this, receiver); }
@Override public StaticMethod asStatic() { return new StaticMethod(this); }
public <R> R invoke(Object... args) { return method.invoke(receiver, args); } }
public void set(T value) { field.set(target, value); } }