All Downloads are FREE. Search and download functionalities are using the official Maven repository.

stalkr.html.parser.TextElementSetter Maven / Gradle / Ivy

There is a newer version: 0.3.1
Show newest version
package stalkr.html.parser;

import java.lang.reflect.Field;

import lombok.RequiredArgsConstructor;

import org.jsoup.nodes.Element;

@RequiredArgsConstructor
public class TextElementSetter implements Setter {

	final Field field;
	final String selector;

	@Override
	public void bind( final Element document, final Object instance ) {
		try {
			final Element selected = document.select( selector ).first();
			field.set( instance, selected.text() );
		} catch ( IllegalArgumentException | IllegalAccessException e ) {
			throw new RuntimeException( e );
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy