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

com.jdiai.asserts.Condition Maven / Gradle / Ivy

There is a newer version: 1.1.8
Show newest version
package com.jdiai.asserts;

import com.epam.jdi.tools.map.MapArray;
import com.jdiai.interfaces.HasCore;
import com.jdiai.interfaces.HasName;

import java.util.function.Function;

public interface Condition extends Function, HasName {
    MapArray NAMES = new MapArray<>();

    default Condition setName(String name) {
        NAMES.update(hashCode(), name);
        return this;
    }

    default String getName() {
        Integer hash = hashCode();
        return NAMES.has(hash) ? NAMES.get(hash) : "";
    }

    default String getName(HasName element) {
        return getName().replace(" %not%", "")
            .replace(" %no%", "")
            .replace("%element%", "'" + element.getName() + "'");
    }

    default Boolean execute(HasCore element) {
        try {
            return apply(element);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy