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

testdata.ArrayClient Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2010, 2017 itemis AG (http://www.itemis.eu) and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package testdata;

/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
public class ArrayClient {

	public String[] toStringArray(String s1, String s2) {
		return new String[] { s1 , s2 };
	}
	
	public int[] toIntArray(int i1, int i2) {
		return new int[] { i1 , i2 };
	}
	
	public void inplaceToUpperCase(String[] values) {
		for(int i = 0; i < values.length; i++) {
			values[i] = values[i].toUpperCase();
		}
	}
	
	public void inplaceSwap(String[] values) {
		if (values.length != 2)
			throw new IllegalArgumentException("length must be 2");
		String first = values[0];
		values[0] = values[1];
		values[1] = first;
	}
	
	public  T[] swap(T[] values) {
		if (values.length != 2)
			throw new IllegalArgumentException("length must be 2");
		T first = values[0];
		values[0] = values[1];
		values[1] = first;
		return values;
	}
	
	public void inplaceAdd10(int[] values) {
		for(int i = 0; i < values.length; i++) {
			values[i] = values[i] + 10;
		}
	}
	
	public int[] getArray() {
		return new int[]{1,2};
	}
	
	public int[][] getMultiArray() {
		return new int[][]{getArray(),getArray()};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy