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.complexible.common.base.Instrumentor.java

/**
 * Return all the classes loaded into the JVM which extend from the provided class
 * @param theClass the class//from   w  w  w.j ava  2  s  .  c o m
 * @param <T> the base class type
 * @return all the classes extending from the parameter. An empty collection will be returned if this java agent is not installed
 */
public static <T> Collection<Class<? extends T>> instancesOf(Class<T> theClass) {
    Instrumentation aInst = instrumentation();

    if (aInst == null) {
        return Sets.newHashSet();
    }

    Set<Class<? extends T>> aClasses = Sets.newHashSet();

    for (Class<?> aCls : aInst.getAllLoadedClasses()) {
        if (theClass.isAssignableFrom(aCls)) {
            aClasses.add((Class<T>) aCls);
        }
    }

    return aClasses;
}

From source file:com.android.build.gradle.integration.common.utils.DeviceHelper.java

/**
 * Return the set of all ABIs supported by any of the connected devices.
 *///from   w  w  w .  ja v  a 2 s  . c  o m
@NonNull
public static Set<String> getDeviceAbis() throws DeviceException {
    ILogger logger = new StdLogger(StdLogger.Level.VERBOSE);
    ConnectedDeviceProvider deviceProvider = new ConnectedDeviceProvider(SdkHelper.getAdb(),
            DEFAULT_ADB_TIMEOUT_MSEC, logger);
    deviceProvider.init();
    Set<String> abis = Sets.newHashSet();
    for (DeviceConnector deviceConnector : deviceProvider.getDevices()) {
        abis.addAll(deviceConnector.getAbis());
    }
    deviceProvider.terminate();
    return abis;
}

From source file:com.twitter.distributedlog.messaging.RRMultiWriter.java

static <VALUE> Set<ServiceFactory<VALUE, DLSN>> initializeServices(String[] streams,
        DistributedLogClient client) {/*ww w.  ja  v  a  2 s  . c om*/
    Set<ServiceFactory<VALUE, DLSN>> serviceFactories = Sets.newHashSet();
    for (String stream : streams) {
        Service<VALUE, DLSN> service = new StreamWriter(stream, client);
        serviceFactories.add(new SingletonFactory<VALUE, DLSN>(service));
    }
    return serviceFactories;
}

From source file:com.android.build.gradle.internal.dsl.PackagingOptionsImpl.java

public void exclude(String path) {
    if (excludes == null) {
        excludes = Sets.newHashSet();
    }

    excludes.add(path);
}

From source file:us.samcraft.thaumickeeper.tile.TileSpaceKeeper.java

public void forceChunkLoading(Ticket ticket) {
    if (chunkTicket == null) {
        chunkTicket = ticket;//from  ww w  .j a  va2s .com
    }

    isactive = true;
    System.out.println("foo");
    Set<ChunkCoordIntPair> chunks = Sets.newHashSet();
    ChunkCoordIntPair keeperChunk = new ChunkCoordIntPair(xCoord >> 9, zCoord >> 9);
    chunks.add(keeperChunk);
    ForgeChunkManager.forceChunk(ticket, keeperChunk);
}

From source file:com.ogomonkey.common.entity.business.Business.java

public void addPersonal(BusinessPersonal personal) {
    Preconditions.checkNotNull(personal, "personal cannot be null");

    if (null == businessPersonals) {
        businessPersonals = Sets.newHashSet();
    }//  w  w w .j  a va  2 s. co m
    personal.setBusiness(this);
    businessPersonals.add(personal);
}

From source file:com.demigodsrpg.util.schematic.Schematic.java

public Set<Location> getLocations(Location reference) {
    Set<Location> locations = Sets.newHashSet();
    for (Selection cuboid : this) {
        locations.addAll(cuboid.getBlockLocations(reference));
    }/*from w w  w .  ja v a2s.  co  m*/
    return locations;
}

From source file:org.gradle.api.internal.tasks.compile.incremental.jar.JarClasspathSnapshotFactory.java

JarClasspathSnapshot createSnapshot(Iterable<JarArchive> jarArchives) {
    Map<File, JarSnapshot> jarSnapshots = Maps.newHashMap();
    Map<File, HashCode> jarHashes = Maps.newHashMap();
    Set<String> allClasses = Sets.newHashSet();
    Set<String> duplicateClasses = Sets.newHashSet();

    for (JarArchive jar : jarArchives) {
        JarSnapshot snapshot = jarSnapshotter.createSnapshot(jar);
        jarSnapshots.put(jar.file, snapshot);
        jarHashes.put(jar.file, snapshot.getHash());
        for (String c : snapshot.getClasses()) {
            if (!allClasses.add(c)) {
                duplicateClasses.add(c);
            }/*from  w  w  w .  j  a v  a 2s . c om*/
        }
    }
    JarClasspathSnapshotData jarClasspathSnapshotData = new JarClasspathSnapshotData(jarHashes,
            duplicateClasses);
    return new JarClasspathSnapshot(jarSnapshots, jarClasspathSnapshotData);
}

From source file:com.cognifide.aet.executor.xmlparser.xml.CompareConverter.java

@Override
public Compare read(InputNode node) throws Exception {
    Set<ComparatorStep> comparatorSteps = Sets.newHashSet();
    InputNode inputNode;/*from  w  w w. ja va2  s  .c o m*/
    while ((inputNode = node.getNext()) != null) {
        Map<String, String> parameters = getParameters(inputNode);

        String comparator = parameters.get("comparator");
        String name = parameters.get("name");
        String collectorName = parameters.get("collectorName");

        List<DataModifierStep> dataModifierSteps = Lists.newArrayList();
        InputNode childNode;
        while ((childNode = inputNode.getNext()) != null) {
            Map<String, String> dataModifierParameters = getParameters(childNode);
            dataModifierSteps.add(new DataModifierStep(childNode.getName(), dataModifierParameters));
        }

        ComparatorStep comparatorStep = new ComparatorStep(comparator, inputNode.getName(), name, collectorName,
                parameters, dataModifierSteps);
        comparatorSteps.add(comparatorStep);
    }
    return new Compare(comparatorSteps);
}

From source file:com.netflix.curator.x.discovery.server.jetty_resteasy.RestEasyApplication.java

@Override
public Set<Object> getSingletons() {
    Set<Object> singletons = Sets.newHashSet();
    singletons.add(singletonsRef.get().contextSingleton);
    singletons.add(singletonsRef.get().serviceNamesMarshallerSingleton);
    singletons.add(singletonsRef.get().serviceInstanceMarshallerSingleton);
    singletons.add(singletonsRef.get().serviceInstancesMarshallerSingleton);
    return singletons;
}