Example usage for com.google.common.collect Sets newHashSet

List of usage examples for com.google.common.collect Sets newHashSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newHashSet.

Prototype

public static <E> HashSet<E> newHashSet() 

Source Link

Document

Creates a mutable, initially empty HashSet instance.

Usage

From source file:com.topekalabs.pg4j.parse.PGTypeParamH.java

private void validate(Node node) {
    pgTypePs = Sets.newHashSet();

    for (PGType pgType : pgTypes) {
        for (PGTypeP pgTypeP : pgType.getPrimitives()) {
            if (!pgTypePs.add(pgTypeP)) {
                throw new PG4jException(node, "Dublicate type: " + pgTypeP.getName());
            }//w w  w. j  a  va2  s.co m
        }
    }
}

From source file:org.franca.core.dsl.validation.internal.util.GraphUtil.java

public static <V> Set<V> getSinks(IGraphDataSource<V> graphDataSource) {
    Set<V> sinks = Sets.newHashSet();

    for (V s : graphDataSource.getAllNodes()) {
        if (graphDataSource.getTargetNodes(s).size() == 0) {
            sinks.add(s);//from  w  w w.  j ava  2  s  .c  om
        }
    }

    return sinks;
}

From source file:org.eclipse.buildship.core.launch.internal.LaunchConfigurationScope.java

/**
 * Creates a launch configuration scope from the target launch configuration. If the scope
 * information cannot be calculated then the result scope doesn't filter any entries.
 *
 * @param configuration the target launch configuration
 * @return the created scope//from   w  w  w.  j  av  a  2s .c om
 */
public static LaunchConfigurationScope from(ILaunchConfiguration configuration) {
    Set<String> result = Sets.newHashSet();
    try {
        Set<IPackageFragmentRoot> soureFolders = SupportedLaunchConfigType.collectSourceFolders(configuration);
        for (IPackageFragmentRoot sourceFolder : soureFolders) {
            Set<String> scope = scopesFor(sourceFolder.getRawClasspathEntry());
            if (scope == null) {
                return INCLUDE_ALL;
            }
            result.addAll(scope);
        }
        return new FilteringLaunchConfigurationScope(result);
    } catch (CoreException e) {
        CorePlugin.logger().warn("Cannot collect dependency scope information for launch configuration "
                + configuration.getName(), e);
        return INCLUDE_ALL;
    }
}

From source file:cpw.mods.fml.common.modloader.ModLoaderGuiHelper.java

ModLoaderGuiHelper(BaseModProxy mod) {
    this.mod = mod;
    this.ids = Sets.newHashSet();
}

From source file:com.skelril.nitro.registry.item.CustomTool.java

public CustomTool() {
    super(0, 0, ToolMaterial.DIAMOND, Sets.newHashSet());
    this.maxStackSize = __getMaxStackSize();
    this.setCreativeTab(__getCreativeTab());

    this.setMaxDamage(__getMaxUses());
}

From source file:org.cinchapi.concourse.util.TStrings.java

/**
 * Return a set that contains every possible substring of {@code string}
 * excluding pure whitespace strings.// w w  w  . jav  a  2 s .  c om
 * 
 * @param string
 * @return the set of substrings
 */
public static Set<String> getAllSubStrings(String string) {
    Set<String> result = Sets.newHashSet();
    for (int i = 0; i < string.length(); i++) {
        for (int j = i + 1; j <= string.length(); j++) {
            String substring = string.substring(i, j).trim();
            if (!Strings.isNullOrEmpty(substring)) {
                result.add(substring);
            }
        }
    }
    return result;
}

From source file:com.netflix.metacat.metadata.mysql.MySqlServiceUtil.java

/**
 * Returns the list of string having the input ids.
 *
 * @param jdbcTemplate jdbc template/*from   w  w  w.j a va 2 s.co m*/
 * @param sql      query sql
 * @param item     identifier
 * @return list of results
 */
public static Set<String> getValues(final JdbcTemplate jdbcTemplate, final String sql, final Object item) {
    try {
        return jdbcTemplate.query(sql, rs -> {
            final Set<String> result = Sets.newHashSet();
            while (rs.next()) {
                result.add(rs.getString("value"));
            }
            return result;
        }, item);
    } catch (EmptyResultDataAccessException e) {
        return Sets.newHashSet();
    }
}

From source file:com.metamx.common.parsers.ParserUtils.java

public static Set<String> findDuplicates(Iterable<String> fieldNames) {
    Set<String> duplicates = Sets.newHashSet();
    Set<String> uniqueNames = Sets.newHashSet();

    for (String fieldName : fieldNames) {
        String next = fieldName.toLowerCase();
        if (uniqueNames.contains(next)) {
            duplicates.add(next);// ww  w. ja v  a2s.  com
        }
        uniqueNames.add(next);
    }

    return duplicates;
}

From source file:com.chiorichan.permission.PermissionValueEnum.java

public PermissionValueEnum(String name, String val, String def, int len, Set<String> enums) {
    super(name, val, def);
    maxLen = len;/*from  w w  w  .  j  ava2 s  .c  o m*/
    enumList = enums;

    if (enumList == null)
        enumList = Sets.newHashSet();

    if (!enumList.contains(val))
        PermissionManager.getLogger()
                .warning("It would appear that permission '" + name + "' of type 'ENUM' has a value of '" + val
                        + "' which is not in the list of available enums '" + enumList.toString()
                        + "', it would be recommended that this is fixed.");
}

From source file:org.sonar.duplications.detector.suffixtree.SuffixTreeCloneDetectionAlgorithm.java

private static TextSet createTextSet(CloneIndex index, Collection<Block> fileBlocks) {
    Set<ByteArray> hashes = Sets.newHashSet();
    for (Block fileBlock : fileBlocks) {
        hashes.add(fileBlock.getBlockHash());
    }//from  w  ww. j a v  a  2 s  .  co m

    String originResourceId = fileBlocks.iterator().next().getResourceId();
    Map<String, List<Block>> fromIndex = retrieveFromIndex(index, originResourceId, hashes);

    if (fromIndex.isEmpty() && hashes.size() == fileBlocks.size()) {
        // optimization for the case when there is no duplications
        return null;
    }

    return createTextSet(fileBlocks, fromIndex);
}