<commit_before>/*
 * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hazelcast.simulator.protocol.registry;

/**
 * Defines a target type for a Worker to select groups of Workers from the {@link ComponentRegistry}.
 *
 * The type {@link #CLIENT} selects all kinds of client Workers (Java, C#, C++, Python etc.).
 */
public enum TargetType {

    /**
     * Selects all types of Workers.
     */
    ALL,

    /**
     * Selects just member Workers.
     */
    MEMBER,

    /**
     * Selects just client Workers.
     */
    CLIENT,

    /**
     * Selects client Workers if there are any registered, member Workers otherwise.
     *
     * This equates to the old passive members mode.
     */
    PREFER_CLIENT;

    public TargetType resolvePreferClient(boolean hasClientWorkers) {
        if (this != PREFER_CLIENT) {
            return this;
        }
        return (hasClientWorkers ? CLIENT : MEMBER);
    }

    public boolean matches(boolean isMemberWorker) {
        return (this == ALL || (this == MEMBER && isMemberWorker) || (this == CLIENT && !isMemberWorker));
    }

    public String toString(int targetTypeCount) {
        if (this == ALL) {
            if (targetTypeCount == 0) {
                return "all";
            }
            return "" + targetTypeCount;
        }
        if (targetTypeCount == 0) {
            return "all " + name().toLowerCase();
        }
        return targetTypeCount + " " + name().toLowerCase();
    }
}<commit_msg>Cleanup of TargetType.<commit_after>/*
 * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hazelcast.simulator.protocol.registry;

/**
 * Defines a target type for a Worker to select groups of Workers from the {@link ComponentRegistry}.
 *
 * The type {@link #CLIENT} selects all kinds of client Workers (Java, C#, C++, Python etc.).
 */
public enum TargetType {

    /**
     * Selects all types of Workers.
     */
    ALL,

    /**
     * Selects just member Workers.
     */
    MEMBER,

    /**
     * Selects just client Workers.
     */
    CLIENT,

    /**
     * Selects client Workers if there are any registered, member Workers otherwise.
     *
     * This equates to the old passive members mode.
     */
    PREFER_CLIENT;

    public TargetType resolvePreferClient(boolean hasClientWorkers) {
        if (this != PREFER_CLIENT) {
            return this;
        }
        return (hasClientWorkers ? CLIENT : MEMBER);
    }

    public boolean matches(boolean isMemberWorker) {
        return (this == ALL || (this == MEMBER && isMemberWorker) || (this == CLIENT && !isMemberWorker));
    }

    public String toString(int targetTypeCount) {
        if (this == ALL) {
            if (targetTypeCount > 0) {
                return "" + targetTypeCount;
            }
            return "all";
        }
        if (targetTypeCount > 0) {
            return targetTypeCount + " " + name().toLowerCase();
        }
        return "all " + name().toLowerCase();
    }
}
{'fraction_non_alphanumeric': 0.10167435088570735, 'fraction_numerical': 0.006794467362290706, 'mean_word_length': 2.435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5714564', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1103, 'n_words': 418}