<commit_before>package brooklyn.location.basic;

import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import com.google.common.base.Objects;

import brooklyn.location.OsDetails;

@Immutable
public class BasicOsDetails implements OsDetails {

    final String name, arch, version;
    final boolean is64bit;

    /** Sets is64Bit according to value of arch parameter. */
    public BasicOsDetails(String name, String arch, String version) {
       this(name, arch, version, arch != null && arch.contains("64"));
    }

    public BasicOsDetails(String name, String arch, String version, boolean is64Bit) {
        this.name = name; this.arch = arch; this.version = version; this.is64bit = is64Bit;
    }
    
    // TODO: Should be replaced with an enum like Jclouds' OsFamily and isX methods should
    // switch against known cases
    @Nullable
    @Override
    public String getName() {
        return name;
    }

    @Nullable
    @Override
    public String getArch() {
        return arch;
    }

    @Nullable
    @Override
    public String getVersion() {
        return version;
    }

    @Override
    public boolean isWindows() {
        //TODO confirm
        return getName()!=null && getName().toLowerCase().contains("microsoft");
    }

    @Override
    public boolean isLinux() {
        String unices = "centos|debian|fedora|gentoo|linux|rhel|slackware|solaris|suse|ubuntu";
        return getName() != null && Pattern.matches(unices, getName().toLowerCase());
    }

    @Override
    public boolean isMac() {
        return getName()!=null && getName().equals(OsNames.MAC_OS_X);
    }

    @Override
    public boolean is64bit() {
        return is64bit;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(OsDetails.class)
                .omitNullValues()
                .add("name", name)
                .add("version", version)
                .add("arch", arch)
                .toString();
    }

    public static class OsNames {
        public static final String MAC_OS_X = "Mac OS X";
    }
    
    public static class OsArchs {
        public static final String X_86_64 = "x86_64";<commit_msg>Expanded BasicOsDetails.isLinux regex to include any name that contains 'linux', e.g. 'Red Hat Enterprise Linux'<commit_after>package brooklyn.location.basic;

import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import com.google.common.base.Objects;

import brooklyn.location.OsDetails;

@Immutable
public class BasicOsDetails implements OsDetails {

    final String name, arch, version;
    final boolean is64bit;

    /** Sets is64Bit according to value of arch parameter. */
    public BasicOsDetails(String name, String arch, String version) {
       this(name, arch, version, arch != null && arch.contains("64"));
    }

    public BasicOsDetails(String name, String arch, String version, boolean is64Bit) {
        this.name = name; this.arch = arch; this.version = version; this.is64bit = is64Bit;
    }
    
    // TODO: Should be replaced with an enum like Jclouds' OsFamily and isX methods should
    // switch against known cases
    @Nullable
    @Override
    public String getName() {
        return name;
    }

    @Nullable
    @Override
    public String getArch() {
        return arch;
    }

    @Nullable
    @Override
    public String getVersion() {
        return version;
    }

    @Override
    public boolean isWindows() {
        //TODO confirm
        return getName()!=null && getName().toLowerCase().contains("microsoft");
    }

    @Override
    public boolean isLinux() {
        String unices = "(?i)centos|debian|fedora|gentoo|.*linux.*|rhel|slackware|solaris|suse|ubuntu";
        return getName() != null && Pattern.matches(unices, getName());
    }

    @Override
    public boolean isMac() {
        return getName()!=null && getName().equals(OsNames.MAC_OS_X);
    }

    @Override
    public boolean is64bit() {
        return is64bit;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(OsDetails.class)
                .omitNullValues()
                .add("name", name)
                .add("version", version)
                .add("arch", arch)
                .toString();
    }

    public static class OsNames {
        public static final String MAC_OS_X = "Mac OS X";
    }
    
    public static class OsArchs {
        public static final String X_86_64 = "x86_64";
{'fraction_non_alphanumeric': 0.1041529334212261, 'fraction_numerical': 0.01054713249835201, 'mean_word_length': 2.5701960784313727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6539886', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1266, 'n_words': 359}