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

info.novatec.testit.webtester.pagefragments.Image Maven / Gradle / Ivy

package info.novatec.testit.webtester.pagefragments;

import java.io.File;
import java.util.Optional;

import org.apache.commons.lang.StringUtils;

import info.novatec.testit.webtester.pagefragments.annotations.Attribute;
import info.novatec.testit.webtester.pagefragments.annotations.Mapping;
import info.novatec.testit.webtester.pagefragments.traits.Clickable;


@Mapping(tag = "img")
public interface Image extends PageFragment, Clickable {

    /**
     * Returns the src attribute's value as an optional string.
     *
     * @return the optional value of the src attribute
     * @see Attribute
     * @see Optional
     * @since 2.0
     */
    @Attribute("src")
    Optional getSourcePath();

    /**
     * Returns the alt attribute's value as an optional string.
     *
     * @return the optional value of the alt attribute
     * @see Attribute
     * @see Optional
     * @since 2.0
     */
    @Attribute("alt")
    Optional getAlternateText();

    /**
     * Returns the height attribute's value as an integer.
     * The integer's unit is pixels.
     *
     * @return the value of the height attribute
     * @see Attribute
     * @since 2.0
     */
    @Attribute("height")
    Integer getHeight();

    /**
     * Returns the width attribute's value as an integer.
     * The integer's unit is pixels.
     *
     * @return the value of the width attribute
     * @see Attribute
     * @since 2.0
     */
    @Attribute("width")
    Integer getWidth();

    /**
     * Returns the optional file name of this image.
     * This might return an empty optional in case the image does not reference a file.
     *
     * @return the name of the image's file
     * @see #getSourcePath()
     * @see File#getName()
     * @since 2.0
     */
    default Optional getFileName() {
        return getSourcePath().filter(StringUtils::isNotBlank).map(File::new).map(File::getName);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy