List of usage examples for java.util List contains
boolean contains(Object o);
From source file:Main.java
/** * Make a copy of a list where the items are unique. * * @param list The list which may contain duplicates * @return A new list containing only the unique items of the input list *///from w ww . java 2 s . c o m public static <T> List<T> uniqueList(List<T> list) { if (list == null) { return null; } List<T> unique = new ArrayList<T>(list.size()); for (T next : list) { if (!unique.contains(next)) { unique.add(next); } } return unique; }
From source file:Main.java
@NonNull public static <T> List<T> intersection(@NonNull List<T> list1, @NonNull List<T> list2) { List<T> list = new ArrayList<>(); for (T t : list1) { if (list2.contains(t)) { list.add(t);/*from w ww. ja va2s . co m*/ } } return list; }
From source file:jackrabbit.repository.RepositoryManager.java
public static void registerCustomNodeTypes(Session session, String cndPath) throws IOException, RepositoryException, ParseException { if (cndPath == null || cndPath.isEmpty()) { log.error("CND path is null or empty."); return;// w ww . j av a2 s . c o m } NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry(); List<String> prefixes = Arrays.asList(registry.getPrefixes()); if (!prefixes.contains("fsp")) registry.registerNamespace("fsp", "http://www.findlaw.com/jcr/fsp"); if (!prefixes.contains("prop")) registry.registerNamespace("prop", "http://www.findlaw.com/jcr/fsp/prop"); CndImporter.registerNodeTypes(new FileReader(cndPath), session); }
From source file:Main.java
public static void chooseFocusPoint(Camera.Parameters parameters, String focusMode, int x, int y, int width, int height) { List<String> supportedModes = parameters.getSupportedFocusModes(); if (supportedModes != null && supportedModes.contains(focusMode)) { parameters.setFocusMode(focusMode); // Rect focusRect = calculateTapArea(x, y, 1f); // Rect meteringRect = calculateTapArea(x, y, 1.5f); // if (params.getMaxNumFocusAreas() > 0) { // List<Camera.Area> focusAreas = new ArrayList<Camera.Area>(); // focusAreas.add(new Camera.Area(focusRect, 600)); // params.setFocusAreas(focusAreas); // } // if (params.getMaxNumMeteringAreas() > 0) { // List<Camera.Area> meteringAreas = new ArrayList<Camera.Area>(); // meteringAreas.add(new Camera.Area(meteringRect, 600)); // params.setMeteringAreas(meteringAreas); // } }//from w w w . j a v a 2 s .c o m }
From source file:Main.java
public static void chooseFlashMode(Camera.Parameters parameters, String flashMode) { List<String> supportedFlashModes = parameters.getSupportedFlashModes(); if (supportedFlashModes != null) { if (supportedFlashModes.contains(flashMode)) { parameters.setFlashMode(flashMode); }/*from www . j a va 2 s .c om*/ } }
From source file:Main.java
public static void chooseFocusMode(Camera.Parameters parameters, String focusMode) { List<String> supportedFocusModes = parameters.getSupportedFocusModes(); if (supportedFocusModes != null) { if (supportedFocusModes.contains(focusMode)) { parameters.setFocusMode(focusMode); }//from w w w .ja v a 2s . c o m } }
From source file:Main.java
public static void chooseSceneMode(Camera.Parameters parameters, String sceneMode) { List<String> supportedSceneModes = parameters.getSupportedSceneModes(); if (supportedSceneModes != null) { if (supportedSceneModes.contains(sceneMode)) { parameters.setSceneMode(sceneMode); }//w w w . j a va 2 s . co m } }
From source file:Main.java
/** * Safety add element included in source collection to target collection * if target has already had element that is included in source collection, * it doesn't add element to target/*www . j a v a2 s . c o m*/ * * @param src source collection * @param target target collection */ public static void safetyMergeCollection(List src, List target) { for (Iterator it = src.iterator(); it.hasNext();) { Object data = it.next(); if (!target.contains(data)) { target.add(data); } } }
From source file:Main.java
@SafeVarargs public static <T> boolean contains(T[] array, T... toLookFor) { if (array == null) return false; List<T> searchList = new ArrayList<>(Arrays.asList(toLookFor)); for (T element : array) { if (searchList.contains(element)) { searchList.remove(element);/*from w ww .java 2 s .c o m*/ } if (searchList.size() == 0) { return true; } } return false; }
From source file:Main.java
public static boolean setOptimalCameraPreviewSize(Camera camera, int width, int height) { if (camera == null) { return false; }/*from w w w . j av a2 s .c o m*/ double targetRatio = (double) height / width; Camera.Parameters params = camera.getParameters(); List<Camera.Size> sizes = params.getSupportedPreviewSizes(); Camera.Size optimalSize = null; // selecting optimal camera preview size int minDiff = Integer.MAX_VALUE; for (Camera.Size size : sizes) { double ratio = (double) size.height / size.width; if (Math.abs(ratio - targetRatio) > RATIO_TOLERANCE) continue; if (Math.abs(size.height - height) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - height); } } if (optimalSize == null) { minDiff = Integer.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.height - height) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - height); } } } params.setPreviewSize(optimalSize.width, optimalSize.height); List<String> focusModes = params.getSupportedFocusModes(); if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) { params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); } // for Mi3, only support ImageFormat.NV21 // for most cameras, ImageFormat.NV21 are support worldwide // so use default preview format // params.setPreviewFormat(ImageFormat.JPEG); camera.setParameters(params); return true; }