java.util.LinkedHashSet#addAll ( )源码实例Demo

下面列出了java.util.LinkedHashSet#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: obevo   文件: Environment.java
public RichIterable<FileObject> getSourceDirs() {
    if (this.sourceDirs == null) {
        // only keep the distinct list of files here
        LinkedHashSet<FileObject> fileObjects = new LinkedHashSet<FileObject>();
        if (coreSourcePath != null) {
            fileObjects.add(coreSourcePath);
        }
        if (additionalSourceDirs != null) {
            fileObjects.addAll(additionalSourceDirs.flatCollect(new Function<String, Iterable<FileObject>>() {
                @Override
                public Iterable<FileObject> valueOf(String path) {
                    MutableList<FileObject> resolvedFileObjects = Lists.mutable.empty();
                    for (FileResolverStrategy fileResolverStrategy : fileResolverStrategies) {
                        resolvedFileObjects.addAllIterable(fileResolverStrategy.resolveFileObjects(path));
                    }
                    if (resolvedFileObjects.isEmpty()) {
                        throw new IllegalArgumentException("Unable to find the given path [" + path + "] via any of the fileResolverStrategies:" + fileResolverStrategies.makeString(", "));
                    }
                    return resolvedFileObjects;
                }
            }).toList());
        }
        this.sourceDirs = Lists.mutable.withAll(fileObjects);
    }
    return this.sourceDirs;
}
 
/**
 * Post processing the user list, when found membership group filter with user name filtering.
 * Get match users from member list. When found username filtering.
 *
 * @param expressionConditions
 * @param userNames
 * @return
 */
private List<String> getMatchUsersFromMemberList(List<ExpressionCondition> expressionConditions,
                                                 List<String> userNames) {
    /*
    If group filtering and username filtering found, we need to get match users names only.
    'member' filtering retrieve all the members once the conditions matched because 'member' is a
    multi valued attribute.
    */
    List<String> derivedUserList = new ArrayList<>();

    for (ExpressionCondition expressionCondition : expressionConditions) {
        if (ExpressionAttribute.USERNAME.toString().equals(expressionCondition.getAttributeName())) {
            derivedUserList.addAll(getMatchUserNames(expressionCondition, userNames));
        }
    }
    LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>();
    linkedHashSet.addAll(derivedUserList);
    derivedUserList.clear();
    derivedUserList.addAll(linkedHashSet);
    return derivedUserList;
}
 
源代码3 项目: java-n-IDE-for-Android   文件: DeviceManager.java
/**
 * Returns the known {@link Device} list.
 *
 * @param deviceFilter A combination of the {@link DeviceFilter} constants
 *                     or the constant {@link DeviceManager#ALL_DEVICES}.
 * @return A copy of the list of {@link Device}s. Can be empty but not null.
 */
@NonNull
public Collection<Device> getDevices(@NonNull EnumSet<DeviceFilter> deviceFilter) {
    initDevicesLists();
    LinkedHashSet<Device> devices = new LinkedHashSet<Device>();
    if (mUserDevices != null && (deviceFilter.contains(DeviceFilter.USER))) {
        devices.addAll(mUserDevices);
    }
    if (mDefaultDevices != null && (deviceFilter.contains(DeviceFilter.DEFAULT))) {
        devices.addAll(mDefaultDevices);
    }
    if (mVendorDevices != null && (deviceFilter.contains(DeviceFilter.VENDOR))) {
        devices.addAll(mVendorDevices);
    }
    if (mSysImgDevices != null && (deviceFilter.contains(DeviceFilter.SYSTEM_IMAGES))) {
        devices.addAll(mSysImgDevices);
    }
    return Collections.unmodifiableSet(devices);
}
 
源代码4 项目: crate   文件: JoinOrdering.java
private static void buildBestOrderByJoinConditions(List<Set<RelationName>> sets, LinkedHashSet<RelationName> bestOrder) {
    Iterator<Set<RelationName>> setsIterator = sets.iterator();
    while (setsIterator.hasNext()) {
        Set<RelationName> set = setsIterator.next();
        for (RelationName name : set) {
            if (bestOrder.contains(name)) {
                bestOrder.addAll(set);
                setsIterator.remove();
                setsIterator = sets.iterator();
                break;
            }
        }
    }

    // Add the rest of the relations to the end of the collection
    sets.forEach(bestOrder::addAll);
}
 
源代码5 项目: pentaho-reporting   文件: IndexedTableModel.java
public String[] getMetaAttributeNames( final String domainName ) {
  if ( MetaAttributeNames.Core.NAMESPACE.equals( domainName ) == false
      && MetaAttributeNames.Formatting.NAMESPACE.equals( domainName ) == false ) {
    return backend.getMetaAttributeNames( domainName );
  }

  final LinkedHashSet<String> names = new LinkedHashSet<String>();
  names.addAll( Arrays.asList( backend.getMetaAttributeNames( domainName ) ) );
  if ( MetaAttributeNames.Core.NAMESPACE.equals( domainName ) ) {
    names.add( MetaAttributeNames.Core.INDEXED_COLUMN );
    names.add( MetaAttributeNames.Core.NAME );
    names.add( MetaAttributeNames.Core.SOURCE );
    names.add( MetaAttributeNames.Core.TYPE );
  }
  if ( MetaAttributeNames.Formatting.NAMESPACE.equals( domainName ) ) {
    names.add( MetaAttributeNames.Formatting.LABEL );
  }
  return names.toArray( new String[names.size()] );
}
 
源代码6 项目: flink   文件: ExecutionConfig.java
/**
 * 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;
	}
}
 
/**
 * Add a new charset name mapping
 * @param javaName the (supposedly) java name of the charset.
 * @param xmlNames a list of corresponding XML names for that charset.
 */
void addMapping(String javaName, Collection<String> xmlNames) {
    final LinkedHashSet<String> aliasNames = new LinkedHashSet<>();
    aliasNames.add(javaName);
    aliasNames.addAll(xmlNames);
    final String[] aliases = aliasNames.toArray(new String[aliasNames.size()]);
    final String cs = findCharsetNameFor(aliases);
    if (cs != null) {
        registerCharsetNameFor(cs, aliases);
        if (xmlNames.size() > 0) {
            String preferred = xmlNames.iterator().next();
            String cachedPreferred = preferredMime.get(cs.toUpperCase());
            if (cachedPreferred != null && !cachedPreferred.equals(preferred)) {
                throw new ConflictingPreferredMimeNameError(cs, cachedPreferred, preferred);
            }
            preferredMime.put(cs.toUpperCase(), preferred);
        }
    } else {
        registerUnresolvedNamesFor(aliases, aliasNames);
    }
}
 
源代码8 项目: pentaho-reporting   文件: ParameterDialog.java
private void valueChanged() {
  final int count = availableDataSourcesModel.size();
  final LinkedHashSet<String> set = new LinkedHashSet<>();
  for ( int i = 0; i < count; i++ ) {
    final DataFactoryWrapper factoryWrapper = availableDataSourcesModel.get( i );
    if ( factoryWrapper.isRemoved() ) {
      continue;
    }
    final String[] strings = factoryWrapper.getEditedDataFactory().getQueryNames();
    set.addAll( Arrays.asList( strings ) );
  }

  queryComboBoxModel.setValues( set.toArray( new String[ set.size() ] ) );
  final TreePath selectionPath = availableDataSources.getSelectionPath();
  if ( selectionPath == null ) {
    setSelectedQuery( null );
    idComboBox.setModel( new DefaultComboBoxModel() );
    displayValueComboBox.setModel( new DefaultComboBoxModel() );
    return;
  }

  final Object maybeQuery = selectionPath.getLastPathComponent();
  if ( maybeQuery instanceof String ) {
    setSelectedQuery( (String) maybeQuery );
  }
}
 
源代码9 项目: sakai   文件: ListItem.java
/**
 * Asks the Server Configuration Service to get a list of available roles with the prefix "resources.enabled.roles""
 * We should expect language strings for these to be defined in the bundles.
 * @return a set of role ids that can be used
 */
public Set<String> availableRoleIds() {
    String[] configStrings = ServerConfigurationService.getStrings("resources.enabled.roles");

    LinkedHashSet<String> availableIds = new LinkedHashSet<String>();

    if(configStrings != null) {
        availableIds.addAll(Arrays.asList(configStrings));
    } else {
        // By default just include the public
        availableIds.add(PUBVIEW_ROLE);
    }

    return availableIds;
}
 
源代码10 项目: binnavi   文件: CTraceCombinationFunctions.java
/**
 * Calculates the event addresses that appear in any of the traces.
 *
 * @param traces The input traces.
 *
 * @return The addresses of those events that appear in any of the traces.
 */
private static LinkedHashSet<BreakpointAddress> getUnionizedAddresses(
    final List<TraceList> traces) {
  final LinkedHashSet<BreakpointAddress> addresses = new LinkedHashSet<BreakpointAddress>();

  for (final Collection<BreakpointAddress> collection : getTraceAddresses(traces)) {
    addresses.addAll(collection);
  }

  return addresses;
}
 
源代码11 项目: obevo   文件: Db2SqlExecutor.java
/**
 * Package-private for unit testing only.
 */
static String getCurrentPathSql(Connection conn, JdbcHelper jdbc, ImmutableSet<PhysicalSchema> physicalSchemas) {
    String path = jdbc.query(conn, "select current path from sysibm.sysdummy1", new ScalarHandler<String>());

    MutableList<String> currentSchemaPathList = Lists.mutable.of(path.split(",")).collect(new Function<String, String>() {
        @Override
        public String valueOf(String object) {
            if (object.startsWith("\"") && object.endsWith("\"")) {
                return object.substring(1, object.length() - 1);
            } else {
                return object;
            }
        }
    });

    // Rules on constructing this "set path" command:
    // 1) The existing default path must come first (respecting the existing connection), followed by the
    // schemas in our environment. The default path must take precedence.
    // 2) We cannot have duplicate schemas listed in the "set path" call; i.e. in case the schemas in our
    // environment config are already in the default schema.
    //
    // Given these two requirements, we use a LinkedHashSet
    LinkedHashSet<String> currentSchemaPaths = new LinkedHashSet(currentSchemaPathList);
    currentSchemaPaths.addAll(physicalSchemas.collect(new Function<PhysicalSchema, String>() {
        @Override
        public String valueOf(PhysicalSchema physicalSchema) {
            return physicalSchema.getPhysicalName();
        }
    }).castToSet());

    // This is needed to work w/ stored procedures
    // Ideally, we'd use "set current path current path, " + physicalSchemaList
    // However, we can't set this multiple times in a connection, as we can't have dupes in "current path"
    // Ideally, we could use BasicDataSource.initConnectionSqls, but this does not interoperate w/ the LDAP
    // datasource for JNDI-JDBC
    return "set path " + CollectionAdapter.adapt(currentSchemaPaths).makeString(",");
}
 
源代码12 项目: buck   文件: ResourcesLoader.java
@TargetApi(LOLLIPOP)
public static void updateLoadedApkResDirs(Context context) throws Exception {
  List<String> exoResourcePaths = getExoPaths(context);
  if (exoResourcePaths.isEmpty()) {
    return;
  }
  // Split resource loading doesn't interact correctly with WebView's asset loading, so we add
  // the webview assets directly (in the same way that the webview asset-loading does it).
  // If split resource loading didn't replace the base source dir (and just added split resource
  // dirs), I think it would interact fine with webview assets. I'm not sure if this would work
  // on Android <5.0, and it would require using different package id or type ids in the split
  // resources.
  List<String> webviewAssets = getWebViewAssets(context);
  getAssetManager(context).addAssetPaths(webviewAssets, true);
  ApplicationInfo applicationInfo = context.getApplicationInfo();
  LinkedHashSet<String> sharedLibraryFiles = new LinkedHashSet<>();
  if (applicationInfo.sharedLibraryFiles != null) {
    sharedLibraryFiles.addAll(Arrays.asList(applicationInfo.sharedLibraryFiles));
  }
  sharedLibraryFiles.addAll(webviewAssets);
  applicationInfo.sharedLibraryFiles =
      sharedLibraryFiles.toArray(new String[sharedLibraryFiles.size()]);

  String resDir = exoResourcePaths.get(0);
  String[] splitResDirs = new String[exoResourcePaths.size() - 1];
  for (int i = 1; i < exoResourcePaths.size(); i++) {
    splitResDirs[i - 1] = exoResourcePaths.get(i);
  }
  ActivityThreadInternal activityThread = ActivityThreadInternal.currentActivityThread();
  for (LoadedApkInternal loadedApk : activityThread.getLoadedApks()) {
    if (loadedApk.getApplication() == context) {
      loadedApk.setResDir(resDir);
      loadedApk.setSplitResDirs(splitResDirs);
    }
  }
}
 
源代码13 项目: birt   文件: ArchiveView.java
synchronized public List<String> listEntries( String namePattern )
{
	List<String> viewList = view.listEntries( namePattern );
	List<String> archiveList = archive.listEntries( namePattern );

	if ( archiveList.isEmpty() )
	{
		return viewList;
	}

	LinkedHashSet<String> entries = new LinkedHashSet<String>( viewList );
	entries.addAll(archiveList);
	return new ArrayList<String>(entries);
}
 
public String[] getReferencedFields( final String query, final DataRow parameter ) throws ReportDataFactoryException {
  final String[] additionalFields = scriptingSupport.computeAdditionalQueryFields( query, parameter );
  if ( additionalFields == null ) {
    return null;
  }

  final LinkedHashSet<String> fields =
    new LinkedHashSet<String>( Arrays.asList( super.getReferencedFields( query, parameter ) ) );
  fields.addAll( Arrays.asList( additionalFields ) );
  return fields.toArray( new String[ fields.size() ] );
}
 
源代码15 项目: calcite   文件: LatticeSuggester.java
static Set<TableRef> collectTableRefs(List<Frame> inputs, List<Hop> hops) {
  final LinkedHashSet<TableRef> set = new LinkedHashSet<>();
  for (Hop hop : hops) {
    set.add(hop.source.tableRef());
    set.add(hop.target.tableRef());
  }
  for (Frame frame : inputs) {
    set.addAll(frame.tableRefs);
  }
  return set;
}
 
public void setFirstCell(Cell cell) {
    selectedCells.remove(cell);
    LinkedHashSet<Cell> result = new LinkedHashSet<Cell>();
    result.add(cell);
    result.addAll(selectedCells);
    selectedCells = result;
}
 
源代码17 项目: jdk8u-jdk   文件: SystemFlavorMap.java
/**
 * Returns a <code>List</code> of <code>DataFlavor</code>s to which the
 * specified <code>String</code> native can be translated by the data
 * transfer subsystem. The <code>List</code> will be sorted from best
 * <code>DataFlavor</code> to worst. That is, the first
 * <code>DataFlavor</code> will best reflect data in the specified
 * native to a Java application.
 * <p>
 * If the specified native is previously unknown to the data transfer
 * subsystem, and that native has been properly encoded, then invoking this
 * method will establish a mapping in both directions between the specified
 * native and a <code>DataFlavor</code> whose MIME type is a decoded
 * version of the native.
 * <p>
 * If the specified native is not a properly encoded native and the
 * mappings for this native have not been altered with
 * <code>setFlavorsForNative</code>, then the contents of the
 * <code>List</code> is platform dependent, but <code>null</code>
 * cannot be returned.
 *
 * @param nat the native whose corresponding <code>DataFlavor</code>s
 *        should be returned. If <code>null</code> is specified, all
 *        <code>DataFlavor</code>s currently known to the data transfer
 *        subsystem are returned in a non-deterministic order.
 * @return a <code>java.util.List</code> of <code>DataFlavor</code>
 *         objects into which platform-specific data in the specified,
 *         platform-specific native can be translated
 *
 * @see #encodeJavaMIMEType
 * @since 1.4
 */
@Override
public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
    LinkedHashSet<DataFlavor> returnValue = flavorsForNativeCache.check(nat);
    if (returnValue != null) {
        return new ArrayList<>(returnValue);
    } else {
        returnValue = new LinkedHashSet<>();
    }

    if (nat == null) {
        for (String n : getNativesForFlavor(null)) {
            returnValue.addAll(getFlavorsForNative(n));
        }
    } else {
        final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
        if (disabledMappingGenerationKeys.contains(nat)) {
            return new ArrayList<>(flavors);
        }

        final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
                nativeToFlavorLookup(nat);

        for (DataFlavor df : flavorsWithSynthesized) {
            returnValue.add(df);
            if ("text".equals(df.getPrimaryType())) {
                String baseType = df.mimeType.getBaseType();
                returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
            }
        }
    }
    flavorsForNativeCache.put(nat, returnValue);
    return new ArrayList<>(returnValue);
}
 
源代码18 项目: nexus-public   文件: DefaultContentValidator.java
@Nonnull
@Override
public String determineContentType(boolean strictContentTypeValidation,
                                   Supplier<InputStream> contentSupplier,
                                   @Nullable MimeRulesSource mimeRulesSource,
                                   @Nullable String contentName,
                                   @Nullable String declaredContentType) throws IOException
{
  checkNotNull(contentSupplier);
  final String declaredBaseContentType = mediaTypeWithoutParameters(declaredContentType);

  final LinkedHashSet<String> contentDetectedMimeTypes = new LinkedHashSet<>();
  try (InputStream is = contentSupplier.get()) {
    contentDetectedMimeTypes.addAll(mimeSupport.detectMimeTypes(is, contentName));
  }
  adjustIfHtml(contentDetectedMimeTypes);
  log.debug("Mime support detects {} as {}", contentName, contentDetectedMimeTypes);

  if (strictContentTypeValidation && isUnknown(contentDetectedMimeTypes)) {
    throw new InvalidContentException("Content type could not be determined: " + contentName);
  }

  final LinkedHashSet<String> nameAssumedMimeTypes = new LinkedHashSet<>();
  if (contentName != null) {
    nameAssumedMimeTypes.addAll(
        mimeSupport.guessMimeTypesListFromPath(
            contentName,
            mimeRulesSource != null ? mimeRulesSource : MimeRulesSource.NOOP)
    );
    adjustIfHtml(nameAssumedMimeTypes);
    log.debug("Mime support assumes {} as {}", contentName, nameAssumedMimeTypes);

    if (!isUnknown(nameAssumedMimeTypes)) {
      Set<String> intersection = Sets.intersection(contentDetectedMimeTypes, nameAssumedMimeTypes);
      log.debug("content/name types intersection {}", intersection);
      if (strictContentTypeValidation && intersection.isEmpty()) {
        throw new InvalidContentException(
            String.format("Detected content type %s, but expected %s: %s",
                contentDetectedMimeTypes, nameAssumedMimeTypes, contentName)
        );
      }
    }
  }

  String finalContentType;
  if (!isUnknown(nameAssumedMimeTypes)) {
    // format implied type or known extension
    finalContentType = nameAssumedMimeTypes.iterator().next();
  }
  else if (!isUnknown(contentDetectedMimeTypes)) {
    // use the content based one
    finalContentType = contentDetectedMimeTypes.iterator().next();
  }
  else if (!Strings.isNullOrEmpty(declaredBaseContentType)) {
    // use the declared if declared at all
    finalContentType = declaredBaseContentType;
  }
  else {
    // give up
    finalContentType = ContentTypes.APPLICATION_OCTET_STREAM;
  }

  log.debug("Content {} declared as {}, determined as {}", contentName, declaredContentType, finalContentType);

  return finalContentType;
}
 
@Test
public void testMessageDeleiveredInCorrectOrder() throws Exception {

   final LinkedHashSet<Message> received = new LinkedHashSet<>();
   final LinkedHashSet<Message> beforeRollback = new LinkedHashSet<>();
   final LinkedHashSet<Message> afterRollback = new LinkedHashSet<>();

   Connection connection = connectionFactory.createConnection();
   Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
   Destination destination = session.createQueue(destinationName);
   MessageConsumer consumer = session.createConsumer(destination);

   consumer.setMessageListener(new MessageListener() {
      @Override
      public void onMessage(Message message) {
         received.add(message);
      }
   });

   sendMessages();

   session.commit();
   connection.start();

   assertTrue("Pre-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() {
      @Override
      public boolean isSatisified() throws Exception {
         LOG.info("Consumer has received " + received.size() + " messages.");
         return received.size() == MSG_COUNT;
      }
   }));

   beforeRollback.addAll(received);
   received.clear();
   session.rollback();

   assertTrue("Post-Rollback expects to receive: " + MSG_COUNT + " messages.", Wait.waitFor(new Wait.Condition() {
      @Override
      public boolean isSatisified() throws Exception {
         LOG.info("Consumer has received " + received.size() + " messages since rollback.");
         return received.size() == MSG_COUNT;
      }
   }));

   afterRollback.addAll(received);
   received.clear();

   assertEquals(beforeRollback.size(), afterRollback.size());
   assertEquals(beforeRollback, afterRollback);

   Iterator<Message> after = afterRollback.iterator();
   Iterator<Message> before = beforeRollback.iterator();

   while (before.hasNext() && after.hasNext()) {
      TextMessage original = (TextMessage) before.next();
      TextMessage rolledBack = (TextMessage) after.next();

      int originalInt = Integer.parseInt(original.getText());
      int rolledbackInt = Integer.parseInt(rolledBack.getText());

      assertEquals(originalInt, rolledbackInt);
   }

   session.commit();
}
 
源代码20 项目: TencentKona-8   文件: SystemFlavorMap.java
/**
 * Semantically equivalent to 'flavorToNative.get(flav)'. This method
 * handles the case where 'flav' is not found in 'flavorToNative' depending
 * on the value of passes 'synthesize' parameter. If 'synthesize' is
 * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by
 * encoding the DataFlavor's MIME type. Otherwise an empty List is returned
 * and 'flavorToNative' remains unaffected.
 */
private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}