<commit_before>/*
 * Copyright 2013 JBoss Inc
 *
 * 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 org.drools.planner.core.score.buildin.bendable;

import org.drools.planner.core.score.AbstractScore;
import org.drools.planner.core.score.FeasibilityScore;
import org.drools.planner.core.score.Score;

/**
 * This {@link Score} is based on n levels of int constraints.
 * The number of levels is bendable at configuration time.
 * <p/>
 * This class is immutable.
 * <p/>
 * The {@link #getHardLevelCount()} and {@link #getSoftLevelCount()} must be the same as in the
 * {@link BendableScoreDefinition} used.
 * @see Score
 */
public final class BendableScore extends AbstractScore<BendableScore>
        implements FeasibilityScore<BendableScore> {

    public static BendableScore parseScore(int hardLevelCount, int softLevelCount, String scoreString) {
        int levelCount = hardLevelCount + softLevelCount;
        String[] levelStrings = parseLevelStrings(scoreString, levelCount);
        int[] hardScores = new int[hardLevelCount];
        int[] softScores = new int[softLevelCount];
        for (int i = 0; i < hardScores.length; i++) {
            hardScores[i] = Integer.parseInt(levelStrings[i]);
        }
        for (int i = 0; i < softScores.length; i++) {
            softScores[i] = Integer.parseInt(levelStrings[hardScores.length + i]);
        }
        return valueOf(hardScores, softScores);
    }

    public static BendableScore valueOf(int[] hardScores, int[] softScores) {
        return new BendableScore(hardScores, softScores);
    }<commit_msg>javadoc<commit_after>/*
 * Copyright 2013 JBoss Inc
 *
 * 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 org.drools.planner.core.score.buildin.bendable;

import org.drools.planner.core.score.AbstractScore;
import org.drools.planner.core.score.FeasibilityScore;
import org.drools.planner.core.score.Score;

/**
 * This {@link Score} is based on n levels of int constraints.
 * The number of levels is bendable at configuration time.
 * <p/>
 * This class is immutable.
 * <p/>
 * The {@link #getHardLevelCount()} and {@link #getSoftLevelCount()} must be the same as in the
 * {@link BendableScoreDefinition} used.
 * @see Score
 */
public final class BendableScore extends AbstractScore<BendableScore>
        implements FeasibilityScore<BendableScore> {

    public static BendableScore parseScore(int hardLevelCount, int softLevelCount, String scoreString) {
        int levelCount = hardLevelCount + softLevelCount;
        String[] levelStrings = parseLevelStrings(scoreString, levelCount);
        int[] hardScores = new int[hardLevelCount];
        int[] softScores = new int[softLevelCount];
        for (int i = 0; i < hardScores.length; i++) {
            hardScores[i] = Integer.parseInt(levelStrings[i]);
        }
        for (int i = 0; i < softScores.length; i++) {
            softScores[i] = Integer.parseInt(levelStrings[hardScores.length + i]);
        }
        return valueOf(hardScores, softScores);
    }

    /**
     * Creates a new {@link BendableScore}.
     * @param hardScores never null, never change that array afterwards: it must be immutable
     * @param softScores never null, never change that array afterwards: it must be immutable
     * @return never null
     */
    public static BendableScore valueOf(int[] hardScores, int[] softScores) {
        return new BendableScore(hardScores, softScores);
    }
{'fraction_non_alphanumeric': 0.09564436461607544, 'fraction_numerical': 0.00449034575662326, 'mean_word_length': 3.541284403669725, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '7064850', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1245, 'n_words': 436}