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

com.epam.jdi.light.elements.complex.table.NameNum Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
package com.epam.jdi.light.elements.complex.table;

import com.epam.jdi.tools.DataClass;

import java.util.List;

import static com.epam.jdi.tools.LinqUtils.firstIndex;
import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

/**
 * Created by Roman Iovlev on 26.09.2019
 * Email: [email protected]; Skype: roman.iovlev
 */
public class NameNum extends DataClass {
    public int num = 0;
    public String name;

    public boolean hasName() {
        return isNotBlank(name);
    }
    @Override
    public String toString() {
        return hasName()
            ? num > 0 ? super.toString() : name
            : num+"";
    }
    public int getIndex(List headers) {
        return !hasName() ? num  : firstIndex(headers,
                h -> equalsIgnoreCase(h, name))+1;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy