<commit_before>package org.rapidoid.app;

/*
 * #%L
 * rapidoid-app
 * %%
 * Copyright (C) 2014 <NAME>
 * %%
 * 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.
 * #L%
 */

import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;

import org.rapidoid.util.Arr;

public class AppScreens implements Comparator<Class<?>> {

	protected static final String SEARCH_SCREEN = "SearchScreen";

	protected static final String SETTINGS_SCREEN = "SettingsScreen";

	protected static final String ADMIN_SCREEN = "AdminScreen";

	protected static final String[] SPECIAL_SCREENS = { SEARCH_SCREEN, SETTINGS_SCREEN, ADMIN_SCREEN };

	public Class<?>[] constructScreens(Map<String, Class<?>> mainScreens) {

		int screensN = mainScreens.size();
		for (String scr : SPECIAL_SCREENS) {
			if (mainScreens.containsKey(scr)) {
				screensN--;
			}
		}

		Class<?>[] screens = new Class[screensN];
		int ind = 0;
		for (Entry<String, Class<?>> e : mainScreens.entrySet()) {

			if (Arr.indexOf(SPECIAL_SCREENS, e.getKey()) < 0) {
				screens[ind++] = e.getValue();
			}
		}

		Arrays.sort(screens, this);
		return screens;
	}

	@Override
	public int compare(Class<?> o1, Class<?> o2) {
		int cls1 = screenOrder(o1);
		int cls2 = screenOrder(o2);

		return cls1 - cls2;
	}

	protected int screenOrder(Class<?> scrClass) {

		String cls = scrClass.getSimpleName();

		if (cls.equals("HomeScreen")) {
			return -1000;
		}

		if (cls.equals("AboutScreen")) {
			return 1000;
		}

		if (cls.equals("HelpScreen")) {
			return 2000;
		}

		return cls.charAt(0);
	}

}
<commit_msg>Added filtering of dev-mode screens not to be included in the app menu.<commit_after>package org.rapidoid.app;

/*
 * #%L
 * rapidoid-app
 * %%
 * Copyright (C) 2014 <NAME>
 * %%
 * 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.
 * #L%
 */

import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;

import org.rapidoid.security.annotation.DevMode;
import org.rapidoid.util.Arr;
import org.rapidoid.util.Metadata;

public class AppScreens implements Comparator<Class<?>> {

	protected static final String SEARCH_SCREEN = "SearchScreen";

	protected static final String SETTINGS_SCREEN = "SettingsScreen";

	protected static final String ADMIN_SCREEN = "AdminScreen";

	protected static final String[] SPECIAL_SCREENS = { SEARCH_SCREEN, SETTINGS_SCREEN, ADMIN_SCREEN };

	public Class<?>[] constructScreens(Map<String, Class<?>> mainScreens) {

		int screensN = mainScreens.size();
		for (Entry<String, Class<?>> e : mainScreens.entrySet()) {
			Class<?> cls = e.getValue();
			if (isSpecialScreen(cls)) {
				screensN--;
			}
		}

		Class<?>[] screens = new Class[screensN];
		int ind = 0;
		for (Entry<String, Class<?>> e : mainScreens.entrySet()) {
			if (!isSpecialScreen(e.getValue())) {
				screens[ind++] = e.getValue();
			}
		}

		Arrays.sort(screens, this);
		return screens;
	}

	protected boolean isSpecialScreen(Class<?> cls) {
		return Arr.indexOf(SPECIAL_SCREENS, cls.getSimpleName()) >= 0 || Metadata.isAnnotated(cls, DevMode.class);
	}

	@Override
	public int compare(Class<?> o1, Class<?> o2) {
		int cls1 = screenOrder(o1);
		int cls2 = screenOrder(o2);

		return cls1 - cls2;
	}

	protected int screenOrder(Class<?> scrClass) {

		String cls = scrClass.getSimpleName();

		if (cls.equals("HomeScreen")) {
			return -1000;
		}

		if (cls.equals("AboutScreen")) {
			return 1000;
		}

		if (cls.equals("HelpScreen")) {
			return 2000;
		}

		return cls.charAt(0);
	}

}

{'fraction_non_alphanumeric': 0.12695269526952696, 'fraction_numerical': 0.013641364136413642, 'mean_word_length': 3.9359391965255157, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '826003', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1474, 'n_words': 432}