com.github.nscuro.wdm.Architecture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webdriver-manager Show documentation
Show all versions of webdriver-manager Show documentation
Simplifying WebDriver instantiation
package com.github.nscuro.wdm;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.List;
import static java.util.Collections.unmodifiableList;
public enum Architecture {
X86(Arrays.asList("x86", "i386", "i686", "i486", "i86")),
X64(Arrays.asList("amd64", "ia64", "x86_64"));
private final List names;
Architecture(final List names) {
this.names = names;
}
List getNames() {
return unmodifiableList(names);
}
private boolean hasName(final String name) {
return names.contains(name);
}
@Nonnull
public static Architecture getCurrent() {
final String archName = System.getProperty("os.arch").toLowerCase();
return Arrays.stream(values())
.filter(architecture -> architecture.hasName(archName))
.findAny()
.orElseThrow(() -> new IllegalStateException("Unable to determine the current architecture"));
}
}