class OperatingSystemProfileActivator implements ProfileActivator {

    private static final String REGEX_PREFIX = "regex:";

    @Override
    public boolean isActive(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) {<FILL_FUNCTION_BODY>}

    @Override
    public boolean presentInConfig(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) {
        Activation activation = profile.getActivation();

        if (activation == null) {
            return false;
        }

        ActivationOS os = activation.getOs();

        return os != null;
    }

    private boolean ensureAtLeastOneNonNull(ActivationOS os) {
        return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null;
    }

    private boolean determineVersionMatch(String expectedVersion, String actualVersion) {
        String test = expectedVersion;
        boolean reverse = false;
        final boolean result;
        if (test.startsWith(REGEX_PREFIX)) {
            result = actualVersion.matches(test.substring(REGEX_PREFIX.length()));
        } else {
            if (test.startsWith("!")) {
                reverse = true;
                test = test.substring(1);
            }
            result = actualVersion.equals(test);
        }

        return reverse != result;
    }

    private boolean determineArchMatch(String expectedArch, String actualArch) {
        String test = expectedArch;
        boolean reverse = false;

        if (test.startsWith("!")) {
            reverse = true;
            test = test.substring(1);
        }

        boolean result = actualArch.equals(test);

        return reverse != result;
    }

    private boolean determineNameMatch(String expectedName, String actualName) {
        String test = expectedName;
        boolean reverse = false;

        if (test.startsWith("!")) {
            reverse = true;
            test = test.substring(1);
        }

        boolean result = actualName.equals(test);

        return reverse != result;
    }

    private boolean determineFamilyMatch(String family, String actualName) {
        String test = family;
        boolean reverse = false;

        if (test.startsWith("!")) {
            reverse = true;
            test = test.substring(1);
        }

        boolean result = Os.isFamily(test, actualName);

        return reverse != result;
    }
}

        Activation activation = profile.getActivation();

        if (activation == null) {
            return false;
        }

        ActivationOS os = activation.getOs();

        if (os == null) {
            return false;
        }

        boolean active = ensureAtLeastOneNonNull(os);

        String actualOsName = context.getSystemProperties().get("os.name").toLowerCase(Locale.ENGLISH);
        String actualOsArch = context.getSystemProperties().get("os.arch").toLowerCase(Locale.ENGLISH);
        String actualOsVersion = context.getSystemProperties().get("os.version").toLowerCase(Locale.ENGLISH);

        if (active && os.getFamily() != null) {
            active = determineFamilyMatch(os.getFamily(), actualOsName);
        }
        if (active && os.getName() != null) {
            active = determineNameMatch(os.getName(), actualOsName);
        }
        if (active && os.getArch() != null) {
            active = determineArchMatch(os.getArch(), actualOsArch);
        }
        if (active && os.getVersion() != null) {
            active = determineVersionMatch(os.getVersion(), actualOsVersion);
        }

        return active;
    
<no_super_class>