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

org.scijava.convert.ArrayConverters Maven / Gradle / Ivy

/*
 * #%L
 * SciJava Common shared library for SciJava software.
 * %%
 * Copyright (C) 2009 - 2017 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, Max Planck
 * Institute of Molecular Cell Biology and Genetics, University of
 * Konstanz, and KNIME GmbH.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */

package org.scijava.convert;

import org.scijava.Priority;
import org.scijava.plugin.Plugin;
import org.scijava.util.BoolArray;
import org.scijava.util.ByteArray;
import org.scijava.util.CharArray;
import org.scijava.util.DoubleArray;
import org.scijava.util.FloatArray;
import org.scijava.util.IntArray;
import org.scijava.util.LongArray;
import org.scijava.util.ShortArray;

/**
 * Container class for all desired combinations of
 * {@link PrimitiveArrayUnwrapper} and {@link PrimitiveArrayWrapper}
 * implementations.
 *
 * @author Mark Hiner
 */
public class ArrayConverters {

	// -- Integer array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class IntArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return IntArray.class;
		}

		@Override
		public Class getInputType() {
			return int[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class IntArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return int[].class;
		}

		@Override
		public Class getInputType() {
			return IntArray.class;
		}
	}

	// -- Byte array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class ByteArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return ByteArray.class;
		}

		@Override
		public Class getInputType() {
			return byte[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class ByteArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return byte[].class;
		}

		@Override
		public Class getInputType() {
			return ByteArray.class;
		}
	}

	// -- Bool array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class BoolArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return BoolArray.class;
		}

		@Override
		public Class getInputType() {
			return boolean[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class BoolArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return boolean[].class;
		}

		@Override
		public Class getInputType() {
			return BoolArray.class;
		}
	}

	// -- Char array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class CharArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return CharArray.class;
		}

		@Override
		public Class getInputType() {
			return char[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class CharArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return char[].class;
		}

		@Override
		public Class getInputType() {
			return CharArray.class;
		}
	}

	// -- Short array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class ShortArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return ShortArray.class;
		}

		@Override
		public Class getInputType() {
			return short[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class ShortArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return short[].class;
		}

		@Override
		public Class getInputType() {
			return ShortArray.class;
		}
	}

	// -- Float array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class FloatArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return FloatArray.class;
		}

		@Override
		public Class getInputType() {
			return float[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class FloatArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return float[].class;
		}

		@Override
		public Class getInputType() {
			return FloatArray.class;
		}
	}

	// -- Double array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class DoubleArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return DoubleArray.class;
		}

		@Override
		public Class getInputType() {
			return double[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class DoubleArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return double[].class;
		}

		@Override
		public Class getInputType() {
			return DoubleArray.class;
		}
	}

	// -- Long array converters --

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class LongArrayWrapper extends
		PrimitiveArrayWrapper
	{

		@Override
		public Class getOutputType() {
			return LongArray.class;
		}

		@Override
		public Class getInputType() {
			return long[].class;
		}
	}

	@Plugin(type = Converter.class, priority = Priority.HIGH)
	public static class LongArrayUnwrapper extends
		PrimitiveArrayUnwrapper
	{

		@Override
		public Class getOutputType() {
			return long[].class;
		}

		@Override
		public Class getInputType() {
			return LongArray.class;
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy