Java Code Examples for java.util.LinkedHashSet#contains()
The following examples show how to use
java.util.LinkedHashSet#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionConfig.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Returns the registered Kryo types. */ public LinkedHashSet<Class<?>> getRegisteredKryoTypes() { if (isForceKryoEnabled()) { // if we force kryo, we must also return all the types that // were previously only registered as POJO LinkedHashSet<Class<?>> result = new LinkedHashSet<>(); result.addAll(registeredKryoTypes); for(Class<?> t : registeredPojoTypes) { if (!result.contains(t)) { result.add(t); } } return result; } else { return registeredKryoTypes; } }
Example 2
Source File: ScriptApiTracker.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Adds all super-interfaces of pivot to acceptor except those listed in exclude * * @param acceptor * list to add to * @param exclude * exclusion set * @param pivot * interface providing super-interfaces */ private <T extends TClassifier> void includeAdditionsSuperInterfaces2(LinkedHashSet<T> acceptor, LinkedHashSet<T> exclude, T pivot, Class<T> castGuard) { for (ParameterizedTypeRef superApiClassifier : pivot.getSuperClassifierRefs()) { Type superApiDeclaredType = superApiClassifier.getDeclaredType(); if (castGuard.isAssignableFrom(superApiDeclaredType.getClass())) { @SuppressWarnings("unchecked") T superInterface = (T) superApiClassifier.getDeclaredType(); if (!exclude.contains(superInterface)) { acceptor.add(superInterface); } } else { // should we handle this or gracefully skip for broken models? if (logger.isDebugEnabled()) { logger.debug("Oopss ... Casting could not be performed Guard = " + castGuard.getName() + " DeclaredType of superApiClassifier '" + superApiDeclaredType.getClass().getName() + "' "); } } } }
Example 3
Source File: ExecutionConfig.java From flink with Apache License 2.0 | 6 votes |
/** * Returns the registered Kryo types. */ public LinkedHashSet<Class<?>> getRegisteredKryoTypes() { if (isForceKryoEnabled()) { // if we force kryo, we must also return all the types that // were previously only registered as POJO LinkedHashSet<Class<?>> result = new LinkedHashSet<>(); result.addAll(registeredKryoTypes); for(Class<?> t : registeredPojoTypes) { if (!result.contains(t)) { result.add(t); } } return result; } else { return registeredKryoTypes; } }
Example 4
Source File: ObjectiveCSourceFileGenerator.java From j2objc with Apache License 2.0 | 6 votes |
private static void collectType( GeneratedType generatedType, LinkedHashSet<GeneratedType> orderedTypes, Map<String, GeneratedType> typeMap, LinkedHashSet<String> typeHierarchy) { typeHierarchy.add(generatedType.getTypeName()); for (String superType : generatedType.getSuperTypes()) { GeneratedType requiredType = typeMap.get(superType); if (requiredType != null) { if (typeHierarchy.contains(superType)) { ErrorUtil.error("Duplicate type name found in " + typeHierarchy.stream().collect(Collectors.joining("->")) + "->" + superType); return; } collectType(requiredType, orderedTypes, typeMap, typeHierarchy); } } typeHierarchy.remove(generatedType.getTypeName()); orderedTypes.add(generatedType); }
Example 5
Source File: UrlBuilder.java From connector-sdk with Apache License 2.0 | 6 votes |
private static ImmutableSet<String> makeColumnSet(String configKey, Set<String> validColumns) { List<String> columnList = Configuration.getMultiValue(configKey, Collections.emptyList(), Configuration.STRING_PARSER).get(); LinkedHashSet<String> columnSet = new LinkedHashSet<>(); List<String> errors = new ArrayList<>(); for (String name : columnList) { name = name.trim(); if (validColumns != null && !validColumns.contains(name)) { errors.add("invalid: " + name); } else if (columnSet.contains(name)) { errors.add("duplicate: " + name); } else { columnSet.add(name); } } if (!errors.isEmpty()) { throw new InvalidConfigurationException(configKey + " errors: " + errors); } return ImmutableSet.copyOf(columnSet); }
Example 6
Source File: SpriteImage.java From RipplePower with Apache License 2.0 | 6 votes |
/** * * @param polygon * @return */ private static Polygon filterPolygon(Polygon polygon) { Area area = new Area(polygon); Polygon newPoly = new Polygon(); PathIterator it = area.getPathIterator(AffineTransform.getTranslateInstance(0, 0), 0); float[] coords = new float[6]; LinkedHashSet<String> set = new LinkedHashSet<String>(); while (!it.isDone()) { it.currentSegment(coords); Point v = new Point((int) coords[0], (int) coords[1]); if (!set.contains(v.toString())) { newPoly.addPoint(v.x, v.y); set.add(v.toString()); } it.next(); } return newPoly; }
Example 7
Source File: ConfigDefinitionExtractor.java From datacollector with Apache License 2.0 | 6 votes |
/** * Returns true if child creates a dependency with any member(s) of dependencyAncestors. * Also adds the stringified cycle to the cycles list */ private boolean detectCycle(LinkedHashSet<String> dependencyAncestors, Set<String> cycles, final String child) { if (dependencyAncestors.contains(child)) { // Find index of the child in the ancestors list int index = -1; for (String s : dependencyAncestors) { index++; if (s.equals(child)) { break; } } // The cycle starts from the first time the child is seen in the ancestors list // and continues till the end of the list, followed by the child again. cycles.add(Joiner.on(" -> ").join(Iterables.skip(dependencyAncestors, index)) + " -> " + child); return true; } return false; }
Example 8
Source File: SystemFlavorMap.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) { LinkedHashSet<L> list = map.get(hashed); if (list == null) { list = new LinkedHashSet<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } }
Example 9
Source File: RuntimeCheckOnConfiguration.java From toothpick with Apache License 2.0 | 5 votes |
@Override public void checkCyclesStart(Class clazz, String name) { final Pair pair = new Pair(clazz, name); final LinkedHashSet<Pair> linkedHashSet = cycleDetectionStack.get(); if (linkedHashSet.contains(pair)) { throw new CyclicDependencyException(Pair.getClassList(linkedHashSet), clazz); } linkedHashSet.add(pair); }
Example 10
Source File: SystemFlavorMap.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) { LinkedHashSet<L> list = map.get(hashed); if (list == null) { list = new LinkedHashSet<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } }
Example 11
Source File: HoodieAvroUtils.java From hudi with Apache License 2.0 | 5 votes |
/** * Generates a super set of fields from both old and new schema. */ private static LinkedHashSet<Field> getCombinedFieldsToWrite(Schema oldSchema, Schema newSchema) { LinkedHashSet<Field> allFields = new LinkedHashSet<>(oldSchema.getFields()); for (Schema.Field f : newSchema.getFields()) { if (!allFields.contains(f) && !isMetadataField(f.name())) { allFields.add(f); } } return allFields; }
Example 12
Source File: SystemFlavorMap.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) { LinkedHashSet<L> list = map.get(hashed); if (list == null) { list = new LinkedHashSet<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } }
Example 13
Source File: MainLoop.java From Concurnas with MIT License | 5 votes |
private ArrayList<SourceCodeInstance> filterSrcInstances(ArrayList<SourceCodeInstance> srcInstances){ //remove dupes and choose instance which must be compiled if there is a choice between them LinkedHashSet<SourceCodeInstance> filtered = new LinkedHashSet<SourceCodeInstance>(); for(SourceCodeInstance srci : srcInstances) { if(filtered.contains(srci)) { if(srci.mustCompile) { filtered.remove(srci); filtered.add(srci); } }else { filtered.add(srci); } } return new ArrayList<SourceCodeInstance>(filtered); }
Example 14
Source File: SystemFlavorMap.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) { LinkedHashSet<L> list = map.get(hashed); if (list == null) { list = new LinkedHashSet<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } }
Example 15
Source File: TypeUtils.java From coroutines with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean isArrayElementTypeAssignableFrom(ClassInformationRepository repo, Type t, Type u) { Validate.notNull(repo); Validate.notNull(t); Validate.notNull(u); Validate.isTrue(t.getSort() == Type.OBJECT); Validate.isTrue(u.getSort() == Type.OBJECT); ClassInformation ci = repo.getInformation(t.getInternalName()); Validate.isTrue(ci != null, "Unable to find class information for %s", t); LinkedHashSet<String> hierarchy = flattenHierarchy(repo, u.getInternalName()); return hierarchy.contains(t.getInternalName()); }
Example 16
Source File: SQLiteDDLCreator.java From ermasterr with Apache License 2.0 | 5 votes |
private void getReferedTables(final LinkedHashSet<ERTable> referedTables, final ERTable table) { for (final NodeElement nodeElement : table.getReferedElementList()) { if (nodeElement instanceof ERTable) { if (nodeElement != table) { final ERTable referedTable = (ERTable) nodeElement; if (!referedTables.contains(referedTable)) { getReferedTables(referedTables, referedTable); referedTables.add(referedTable); } } } } }
Example 17
Source File: SystemFlavorMap.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) { LinkedHashSet<L> list = map.get(hashed); if (list == null) { list = new LinkedHashSet<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } }
Example 18
Source File: JavaProject.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * If a cycle is detected, then cycleParticipants contains all the paths of projects involved in this cycle (directly and indirectly), * no cycle if the set is empty (and started empty) * @param prereqChain ArrayList * @param cycleParticipants HashSet * @param workspaceRoot IWorkspaceRoot * @param traversed HashSet * @param preferredClasspaths Map */ public void updateCycleParticipants( ArrayList prereqChain, LinkedHashSet cycleParticipants, IWorkspaceRoot workspaceRoot, HashSet traversed, Map preferredClasspaths){ IPath path = getPath(); prereqChain.add(path); traversed.add(path); try { IClasspathEntry[] classpath = null; if (preferredClasspaths != null) classpath = (IClasspathEntry[])preferredClasspaths.get(this); if (classpath == null) classpath = getResolvedClasspath(); for (int i = 0, length = classpath.length; i < length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT){ IPath prereqProjectPath = entry.getPath(); int index = cycleParticipants.contains(prereqProjectPath) ? 0 : prereqChain.indexOf(prereqProjectPath); if (index >= 0) { // refer to cycle, or in cycle itself for (int size = prereqChain.size(); index < size; index++) { cycleParticipants.add(prereqChain.get(index)); } } else { if (!traversed.contains(prereqProjectPath)) { IResource member = workspaceRoot.findMember(prereqProjectPath); if (member != null && member.getType() == IResource.PROJECT){ JavaProject javaProject = (JavaProject)JavaCore.create((IProject)member); javaProject.updateCycleParticipants(prereqChain, cycleParticipants, workspaceRoot, traversed, preferredClasspaths); } } } } } } catch(JavaModelException e){ // project doesn't exist: ignore } prereqChain.remove(path); }
Example 19
Source File: XDataTransferer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } String charset = df.getParameter("charset"); String baseType = df.getPrimaryType() + "/" + df.getSubType(); String mimeType = baseType; if (charset != null && DataFlavorUtil.isFlavorCharsetTextType(df)) { mimeType += ";charset=" + charset; } // Add a mapping to the MIME native whenever the representation class // doesn't require translation. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (String mime : mimeTypes) { Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType(mime); while (writers.hasNext()) { ImageWriter imageWriter = writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mime); break; } } } } } else if (DataFlavorUtil.isFlavorCharsetTextType(df)) { // stringFlavor is semantically equivalent to the standard // "text/plain" MIME type. if (DataFlavor.stringFlavor.equals(df)) { baseType = "text/plain"; } for (String encoding : DataFlavorUtil.standardEncodings()) { if (!encoding.equals(charset)) { natives.add(baseType + ";charset=" + encoding); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 20
Source File: XDataTransferer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } String charset = df.getParameter("charset"); String baseType = df.getPrimaryType() + "/" + df.getSubType(); String mimeType = baseType; if (charset != null && DataTransferer.isFlavorCharsetTextType(df)) { mimeType += ";charset=" + charset; } // Add a mapping to the MIME native whenever the representation class // doesn't require translation. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); break; } } } } } else if (DataTransferer.isFlavorCharsetTextType(df)) { // stringFlavor is semantically equivalent to the standard // "text/plain" MIME type. if (DataFlavor.stringFlavor.equals(df)) { baseType = "text/plain"; } for (String encoding : DataTransferer.standardEncodings()) { if (!encoding.equals(charset)) { natives.add(baseType + ";charset=" + encoding); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }