Here you can find the source of indexOfFactory(List> factories, Class> classInstance)
Parameter | Description |
---|---|
factories | All factories. |
classInstance | All class instances. |
protected static int indexOfFactory(List<?> factories, Class<?> classInstance)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Karlsruhe Institute of Technology, Germany * Technical University Darmstadt, Germany * Chalmers University of Technology, Sweden * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w.j a v a 2s . c om * Technical University Darmstadt - initial API and implementation and/or initial documentation *******************************************************************************/ import java.util.Iterator; import java.util.List; public class Main { /** * Returns the index of the factory with the given class in the {@link List}. * @param factories All factories. * @param classInstance All class instances. * @return The index or {@code -1} if it was not found. */ protected static int indexOfFactory(List<?> factories, Class<?> classInstance) { int result = -1; Iterator<?> iter = factories.iterator(); int i = 0; while (result < 0 && iter.hasNext()) { if (classInstance.equals(iter.next().getClass())) { result = i; } i++; } return result; } }