<commit_before>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2022 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/

package org.jtrfp.trcl.shell;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import org.jtrfp.trcl.coll.CollectionActionDispatcher;
import org.jtrfp.trcl.conf.ui.ConfigByUI;
import org.jtrfp.trcl.core.Feature;
import org.jtrfp.trcl.core.FeatureFactory;
import org.jtrfp.trcl.core.FeatureNotApplicableException;
import org.jtrfp.trcl.flow.GameVersion;
import org.jtrfp.trcl.shell.GameShellFactory.GameShell;
import org.springframework.stereotype.Component;

import lombok.Getter;

@Component
public class GameCampaignRegistryFactory implements FeatureFactory<GameShell> { 
    
    public static class GameCampaignRegistry implements Feature<GameShell> {
	@Getter(onMethod=@__({@ConfigByUI(editorClass=GameCampaignListUI.class)}))
	private final CollectionActionDispatcher<GameCampaignData> campaigns = new CollectionActionDispatcher<>(new ArrayList<>());
	
	public GameCampaignRegistry() {
	    final GameCampaignData f3 = new GameCampaignData();
	    f3.setGameVersion(GameVersion.F3);
	    f3.setName("Fury3");
	    final GameCampaignData fZone = new GameCampaignData();
	    fZone.setGameVersion(GameVersion.FURYSE);
	    fZone.setName("F!Zone");
	    final GameCampaignData tv = new GameCampaignData();
	    tv.setGameVersion(GameVersion.TV);
	    tv.setName("Terminal Velocity");
	    setCampaignEntriesCollection(Arrays.asList(f3,fZone,tv));
	}

	@Override
	public void apply(GameShell target) {
	}//end apply()

	@Override
	public void destruct(GameShell target) {
	}
	
	public Collection<GameCampaignData> getCampaignEntriesCollection() {
	    return campaigns.getDelegate();
	}
	
	public void setCampaignEntriesCollection(Collection<GameCampaignData> entries) {
	    campaigns.clear();
	    campaigns.addAll(entries);
	}
	
    }//end GameResourceRegistry

    @Override
    public Feature<GameShell> newInstance(GameShell target)
	    throws FeatureNotApplicableException {
	return new GameCampaignRegistry();
    }

    @Override
    public Class<GameShell> getTargetClass() {
	return GameShell.class;
    }

    @Override
    public Class<? extends Feature<GameShell>> getFeatureClass() {
	return GameCampaignRegistry.class;
    }

}//end GameResourceRegistryFactory
<commit_msg>⟴Default config to GameCampaignRegistryFactory.<commit_after>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2022 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/

package org.jtrfp.trcl.shell;

import java.util.ArrayList;
import java.util.Collection;

import org.jtrfp.trcl.coll.CollectionActionDispatcher;
import org.jtrfp.trcl.conf.ui.ConfigByUI;
import org.jtrfp.trcl.core.Feature;
import org.jtrfp.trcl.core.FeatureFactory;
import org.jtrfp.trcl.core.FeatureNotApplicableException;
import org.jtrfp.trcl.flow.GameVersion;
import org.jtrfp.trcl.shell.GameShellFactory.GameShell;
import org.springframework.stereotype.Component;

@Component
public class GameCampaignRegistryFactory implements FeatureFactory<GameShell> {
    
    public static class GameCampaignRegistry implements Feature<GameShell> {
	
	private final CollectionActionDispatcher<GameCampaignData> campaigns = new CollectionActionDispatcher<>(new ArrayList<>());
	
	public GameCampaignRegistry() {}

	private void ensureCampaignDataIsPopulated() { //Fill with default if empty
	    if(campaigns.isEmpty()) {
		final GameCampaignData f3 = new GameCampaignData();
		f3.setGameVersion(GameVersion.F3);
		f3.setName("Microsoft Fury3");
		final GameCampaignData fZone = new GameCampaignData();
		fZone.setGameVersion(GameVersion.FURYSE);
		fZone.setName("F!Zone");
		final GameCampaignData tv = new GameCampaignData();
		tv.setGameVersion(GameVersion.TV);
		tv.setName("Terminal Velocity");
		campaigns.add(f3);
		campaigns.add(fZone);
		campaigns.add(tv);
	    }
	}//end ensureCampaignDataIsPopulated
	
	@ConfigByUI(editorClass=GameCampaignListUI.class)
	public CollectionActionDispatcher<GameCampaignData> getCampaigns() {
	    ensureCampaignDataIsPopulated();
	    return campaigns;
	}

	@Override
	public void apply(GameShell target) {
	}//end apply()

	@Override
	public void destruct(GameShell target) {
	}
	
	public Collection<GameCampaignData> getCampaignEntriesCollection() {
	    return campaigns.getDelegate();
	}
	
	public void setCampaignEntriesCollection(Collection<GameCampaignData> entries) {
	    campaigns.clear();
	    campaigns.addAll(entries);
	}
	
    }//end GameResourceRegistry

    @Override
    public Feature<GameShell> newInstance(GameShell target)
	    throws FeatureNotApplicableException {
	return new GameCampaignRegistry();
    }

    @Override
    public Class<GameShell> getTargetClass() {
	return GameShell.class;
    }

    @Override
    public Class<? extends Feature<GameShell>> getFeatureClass() {
	return GameCampaignRegistry.class;
    }

}//end GameResourceRegistryFactory

{'fraction_non_alphanumeric': 0.14356435643564355, 'fraction_numerical': 0.004096961420279959, 'mean_word_length': 5.2, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '5832170', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1642, 'n_words': 369}