package org.musetest.core.resource.generic;

import org.musetest.core.resource.*;
import org.musetest.core.values.*;

import java.util.*;

/**
 * A MuseResource that uses a general set of configuration parameters. It is intended for resources which
 * have a few basic configurations for the user to supply. When used in conjunction with with the supported
 * annotations, the IDE can generate an editor for those configuration settings  without needing custom UI code.
 *
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
public abstract class GenericResourceConfiguration extends BaseMuseResource
	{
	/**
	 * Used for JSON serialization. Use parameters() to get access to the sub-sources
	 * for this configuration.
	 */
	public Map<String, ValueSourceConfiguration> getParameters()
		{
		return _parameters.getSourceMap();
		}

	public void setParameters(Map<String, ValueSourceConfiguration> sources)
		{
		_parameters.setSourceMap(sources);
		}

	public NamedSourcesContainer parameters()
		{
		return _parameters;
		}

	private NamedSourcesContainer _parameters = new NamedSourcesContainer();
	}
@@ -38,16 +38,87 @@
 neric;%0A%0A
+import com.fasterxml.jackson.annotation.*;%0Aimport org.musetest.core.*;%0A
 import o
@@ -1187,11 +1187,529 @@
 ainer();
+%0A%0A%09@SuppressWarnings(%22unused%22)  // expect extensions to use this%0A%09@JsonIgnore%0A%09protected boolean isParameterTrue(MuseExecutionContext context, String name)%0A%09%09%7B%0A%09%09if (_parameters != null)%0A%09%09%09%7B%0A%09%09%09try%0A%09%09%09%09%7B%0A%09%09%09%09MuseValueSource source = BaseValueSource.getValueSource(_parameters, name, true, context.getProject());%0A%09%09%09%09return BaseValueSource.getValue(source, context, false, Boolean.class);%0A%09%09%09%09%7D%0A%09%09%09catch (MuseInstantiationException %7C ValueSourceResolutionError e)%0A%09%09%09%09%7B%0A%09%09%09%09return false;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09return false;%0A%09%09%7D
 %0A%09%7D

Add convenience method for getting boolean sub-source values.