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

io.guise.framework.component.transfer.Transferable Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
/*
 * Copyright © 2005-2008 GlobalMentor, Inc. 
 *
 * 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.
 */

package io.guise.framework.component.transfer;

import com.globalmentor.net.MediaType;

/**
 * An object that can be transferred, such as between components using drag and drop.
 * @param  The source of the transfer.
 * @author Garret Wilson
 */
public interface Transferable {

	/** @return The source of the transferable data. */
	public S getSource();

	/** @return The content types available for this transfer. */
	public MediaType[] getContentTypes();

	/**
	 * Determines whether this transferable can transfer data with the given content type.
	 * @param contentType The type of data requested, which may include wildcards.
	 * @return true if this object can transfer data with the requested content type.
	 */
	public boolean canTransfer(final MediaType contentType);

	/**
	 * Transfers data using the given content type.
	 * @param contentType The type of data expected.
	 * @return The transferred data, which may be null.
	 * @throws IllegalArgumentException if the given content type is not supported.
	 */
	public Object transfer(final MediaType contentType);

	/**
	 * Transfers data of the given class.
	 * @param  The type of object to be transferred.
	 * @param objectClass The class of object to return.
	 * @return The transferred data object, which may be null.
	 * @throws IllegalArgumentException if the given class is not supported.
	 */
	public  T transfer(final Class objectClass);
}