All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yarnandtail.andhow.compile.TooManyInitClassesException Maven / Gradle / Ivy

Go to download

Compile-time annotation processor that records all AndHow Properties and registers them as service providers to be picked up at runtime.

There is a newer version: 1.5.0
Show newest version
package org.yarnandtail.andhow.compile;

import java.util.ArrayList;
import java.util.List;
import org.yarnandtail.andhow.compile.AndHowCompileProcessor.CauseEffect;
import org.yarnandtail.andhow.util.AndHowLog;

/**
 *
 * @author ericeverman
 */
public class TooManyInitClassesException extends RuntimeException {
	protected List _instances = new ArrayList();
	protected String _fullInitClassName;
			
	public TooManyInitClassesException(
			String fullInitClassName,
			List instances) {
		if (instances != null) this._instances.addAll(instances);
		this._fullInitClassName = fullInitClassName;
	}
	
	public List getInstanceNames() {
		List names = new ArrayList();

		for (CauseEffect ce : _instances) {
			names.add(ce.fullClassName);
		}
		
		return names;
	}
	
	public void writeDetails(AndHowLog log) {
		log.error("Multiple ({0}) {1} implementation classes were found, but only "
				+ "one is allowed.  List follows:",
				Integer.valueOf(_instances.size()).toString(), _fullInitClassName);
		
		for (String name : getInstanceNames()) {
			log.error("\t* " + name);
		}
	}

	@Override
	public String getMessage() {
		return "Multiple " + _fullInitClassName + " implementations were found - "
				+ "only one is allowed. See System.err for complete list";
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy