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

org.ioc.commons.impl.android.ui.IsWidgetImpl Maven / Gradle / Ivy

package org.ioc.commons.impl.android.ui;

import org.ioc.commons.ui.IsWidget;

import android.view.View;
import android.view.ViewParent;

public class IsWidgetImpl implements IsWidget {

	private View view;
	private ViewParent viewParent;

	public IsWidgetImpl(ViewParent viewParent) {
		this.viewParent = viewParent;
	}

	public IsWidgetImpl(View view) {
		this.view = view;
	}

	@Override
	public Object asWidget() {
		return view != null ? view : viewParent;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((view == null) ? 0 : view.hashCode());
		result = prime * result + ((viewParent == null) ? 0 : viewParent.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IsWidgetImpl other = (IsWidgetImpl) obj;
		if (view == null) {
			if (other.view != null)
				return false;
		} else if (!view.equals(other.view))
			return false;
		if (viewParent == null) {
			if (other.viewParent != null)
				return false;
		} else if (!viewParent.equals(other.viewParent))
			return false;
		return true;
	}

	@Override
	public IsWidget getWidgetParent() {
		return this.view != null ? (this.view.getParent() != null ? new IsWidgetImpl(this.view.getParent()) : null)
				: (this.viewParent.getParent() != null ? new IsWidgetImpl(this.viewParent.getParent()) : null);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy