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

net.projectmonkey.object.mapper.analysis.result.PropertyConfiguration Maven / Gradle / Ivy

package net.projectmonkey.object.mapper.analysis.result;

/*
 *
 *  * Copyright 2012 the original author or authors.
 *  *
 *  * 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.
 *
 */

import net.projectmonkey.object.mapper.annotations.group.Group;
import net.projectmonkey.object.mapper.construction.converter.Converter;
import net.projectmonkey.object.mapper.construction.postprocessor.PostProcessor;
import net.projectmonkey.object.mapper.construction.rule.MappingRule;
import net.projectmonkey.object.mapper.util.CollectionUtil;

/**
 * @author Andy Moody
 */
public class PropertyConfiguration
{

	private Class group;
	private boolean included;
	private Class converter;
	private Class[] rules;
	private Class postProcessor;

	public PropertyConfiguration(final Class group, final boolean included, final Class converter,
								 final Class[] rules, final Class postProcessor)
	{
		this.group = group;
		this.included = included;
		this.converter = converter;
		this.rules = rules;
		this.postProcessor = postProcessor;
	}

	public PropertyConfiguration(final Group group)
	{
		this(group.value(), group.include(), group.converter(), group.rules(), group.postProcessor());
	}

	public Class getGroup()
	{
		return group;
	}

	public Class getConverter()
	{
		return converter;
	}

	public Class[] getRules()
	{
		return rules;
	}

	public boolean isIncluded()
	{
		return included;
	}

	public Class getPostProcessor()
	{
		return postProcessor;
	}

	public void merge(PropertyConfiguration other)
	{
		if(converter == Converter.class)
		{
			converter = other.getConverter();
		}
		if(postProcessor == PostProcessor.class)
		{
			postProcessor = other.getPostProcessor();
		}
		this.rules = CollectionUtil.addToWithoutDuplicates(this.getRules(), other.getRules());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy