info.novatec.testit.webtester.pagefragments.TableRow Maven / Gradle / Ivy
package info.novatec.testit.webtester.pagefragments;
import java.util.List;
import java.util.stream.Stream;
import info.novatec.testit.webtester.pagefragments.annotations.IdentifyUsing;
import info.novatec.testit.webtester.pagefragments.annotations.Mapping;
import info.novatec.testit.webtester.pagefragments.identification.producers.XPath;
@Mapping(tag = "tr")
public interface TableRow extends PageFragment {
/**
* Returns a list of this {@link TableRow row's} {@link TableField fields}.
*
* These are only the direct children of this row. Nested tables / rows will not be resolved!
*
* @return the fields of this row
* @see TableField
* @see TableRow
* @see Table
* @since 2.0
*/
@IdentifyUsing(value = "./th|./td", how = XPath.class)
List fields();
/**
* Returns a stream of this {@link TableRow row's} {@link TableField fields}.
*
* This is equivalent to calling {@link #fields()}.stream()
.
*
* @return the fields of this row
* @see TableField
* @see TableRow
* @see Table
* @since 2.0
*/
default Stream streamFields() {
return fields().stream();
}
/**
* Returns the {@link TableField fields} for the given index. The index starts with 0
for the first field.
*
* @param index the zero-based index of the field to return
* @return the field
* @throws IndexOutOfBoundsException in case there is no field for the given index
* @see TableField
* @see TableRow
* @see Table
* @since 2.0
*/
default TableField getField(int index) {
return fields().get(index);
}
/**
* Returns the number of {@link TableField fields} of this {@link TableRow row}.
*
* @return the number of fields of this row
* @see TableField
* @see TableRow
* @see Table
* @since 2.0
*/
default long getNumberOfFields() {
return fields().size();
}
}