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

org.robobinding.binder.ResolvedBindingAttributesForView Maven / Gradle / Ivy

There is a newer version: 0.8.14
Show newest version
package org.robobinding.binder;

import java.util.Collection;
import java.util.List;

import org.robobinding.BindingContext;
import org.robobinding.viewattribute.AttributeBindingException;
import org.robobinding.viewattribute.ViewAttributeBinder;
import org.robobinding.viewattribute.grouped.AttributeGroupBindingException;

import com.google.common.collect.Lists;

/**
 * 
 * @since 1.0
 * @version $Revision: 1.0 $
 * @author Robert Taylor
 * @author Cheng Wei
 */
public class ResolvedBindingAttributesForView {
	private Object view;
	private final List viewAttributes;

	ResolvedBindingAttributesForView(Object view, Collection viewAttributes) {
		this.view = view;
		this.viewAttributes = Lists.newArrayList(viewAttributes);
	}

	public ViewBindingErrors bindTo(BindingContext bindingContext) {
		ViewBindingErrors viewBindingError = new ViewBindingErrors(view);
		for (ViewAttributeBinder viewAttribute : viewAttributes) {
			try {
				viewAttribute.bindTo(bindingContext);
			} catch (AttributeBindingException e) {
				viewBindingError.addAttributeError(e);
			} catch (AttributeGroupBindingException e) {
				viewBindingError.addAttributeGroupError(e);
			}
		}

		return viewBindingError;
	}

	public void preinitializeView(BindingContext bindingContext) {
		for (ViewAttributeBinder viewAttribute : viewAttributes) {
			viewAttribute.preInitializeView(bindingContext);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy