Java Code Examples for com.google.common.collect.ImmutableSet.of()

The following are Jave code examples for showing how to use of() of the com.google.common.collect.ImmutableSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: andbg   File: ParameterIterator.java   View Source Code Vote up 6 votes
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example 2
Project: hadoop   File: BloomFilterCommonTester.java   View Source Code Vote up 6 votes
private BloomFilterCommonTester(int hashId, int numInsertions) {
  this.hashType = hashId;
  this.numInsertions = numInsertions;

  this.preAssertionHelper = new PreAssertionHelper() {

    @Override
    public ImmutableSet<Integer> falsePositives(int hashId) {
      switch (hashId) {
      case Hash.JENKINS_HASH: {
        // // false pos for odd and event under 1000
        return ImmutableSet.of(99, 963);
      }
      case Hash.MURMUR_HASH: {
        // false pos for odd and event under 1000
        return ImmutableSet.of(769, 772, 810, 874);
      }
      default: {
        // fail fast with unknown hash error !!!
        Assert.assertFalse("unknown hash error", true);
        return ImmutableSet.of();
      }
      }
    }
  };
}
 
Example 3
Project: athena   File: AdjacencyListsGraphTest.java   View Source Code Vote up 5 votes
@Test
public void equality() {
    Set<TestVertex> vertexes = ImmutableSet.of(A, B, C, D, E, F);
    Set<TestVertex> vertexes2 = ImmutableSet.of(A, B, C, D, E, F, G);

    AdjacencyListsGraph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(vertexes, edges);
    AdjacencyListsGraph<TestVertex, TestEdge> same = new AdjacencyListsGraph<>(vertexes, edges);
    AdjacencyListsGraph<TestVertex, TestEdge> different = new AdjacencyListsGraph<>(vertexes2, edges);

    new EqualsTester()
            .addEqualityGroup(graph, same)
            .addEqualityGroup(different)
            .testEquals();
}
 
Example 4
Project: athena   File: PceManagerTest.java   View Source Code Vote up 5 votes
@Override
public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
    // If either edge is null, bail with no paths.
    if (src == null || dst == null) {
        return ImmutableSet.of();
    }

    // Otherwise get all paths between the source and destination edge
    // devices.
    computedPaths = topologyService.getPaths(null, (DeviceId) src, (DeviceId) dst, weight);
    return computedPaths;
}
 
Example 5
Project: athena   File: AdjacencyListsGraphTest.java   View Source Code Vote up 5 votes
@Test
public void basics() {
    Set<TestVertex> vertexes = ImmutableSet.of(A, B, C, D, E, F);
    AdjacencyListsGraph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(vertexes, edges);
    assertEquals("incorrect vertex count", 6, graph.getVertexes().size());
    assertEquals("incorrect edge count", 5, graph.getEdges().size());

    assertEquals("incorrect egress edge count", 1, graph.getEdgesFrom(A).size());
    assertEquals("incorrect ingress edge count", 1, graph.getEdgesTo(A).size());
    assertEquals("incorrect ingress edge count", 1, graph.getEdgesTo(C).size());
    assertEquals("incorrect egress edge count", 2, graph.getEdgesFrom(B).size());
    assertEquals("incorrect ingress edge count", 2, graph.getEdgesTo(D).size());
}
 
Example 6
Project: athena   File: HostToHostIntent.java   View Source Code Vote up 5 votes
/**
 * Creates a new host-to-host intent with the supplied host pair.
 *
 * @param appId       application identifier
 * @param key       intent key
 * @param one         first host
 * @param two         second host
 * @param selector    action
 * @param treatment   ingress port
 * @param constraints optional prioritized list of path selection constraints
 * @param priority    priority to use for flows generated by this intent
 * @throws NullPointerException if {@code one} or {@code two} is null.
 */
private HostToHostIntent(ApplicationId appId, Key key,
                        HostId one, HostId two,
                        TrafficSelector selector,
                        TrafficTreatment treatment,
                        List<Constraint> constraints,
                        int priority) {
    super(appId, key, ImmutableSet.of(one, two), selector, treatment,
          constraints, priority);

    // TODO: consider whether the case one and two are same is allowed
    this.one = checkNotNull(one);
    this.two = checkNotNull(two);

}
 
Example 7
Project: athena   File: PathManager.java   View Source Code Vote up 5 votes
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
    checkPermission(TOPOLOGY_READ);
    checkNotNull(src, ELEMENT_ID_NULL);
    checkNotNull(dst, ELEMENT_ID_NULL);

    // Get the source and destination edge locations
    EdgeLink srcEdge = getEdgeLink(src, true);
    EdgeLink dstEdge = getEdgeLink(dst, false);

    // If either edge is null, bail with no paths.
    if (srcEdge == null || dstEdge == null) {
        return ImmutableSet.of();
    }

    DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
    DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;

    // If the source and destination are on the same edge device, there
    // is just one path, so build it and return it.
    if (srcDevice.equals(dstDevice)) {
        return edgeToEdgePathsDisjoint(srcEdge, dstEdge);
    }

    // Otherwise get all paths between the source and destination edge
    // devices.
    Topology topology = topologyService.currentTopology();
    Set<DisjointPath> paths = weight == null ?
            topologyService.getDisjointPaths(topology, srcDevice, dstDevice) :
            topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight);

    return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
}
 
Example 8
Project: athena   File: DefaultGraphDescriptionTest.java   View Source Code Vote up 5 votes
@Test
public void basics() {
    DefaultGraphDescription desc =
            new DefaultGraphDescription(4321L, System.currentTimeMillis(), ImmutableSet.of(DEV1, DEV2, DEV3),
                                        ImmutableSet.of(L1, L2));
    assertEquals("incorrect time", 4321L, desc.timestamp());
    assertEquals("incorrect vertex count", 3, desc.vertexes().size());
    assertEquals("incorrect edge count", 2, desc.edges().size());
}
 
Example 9
Project: morf   File: TestViewChanges.java   View Source Code Vote up 5 votes
/**
 * Test we're still prepared to drop views that we know nothing of.
 */
@Test
public void testObsoleted() {
  ViewChanges c = new ViewChanges(
    ImmutableSet.of(
      view("A", "B"),
      view("B", "C"),
      view("C")
    ),
    ImmutableSet.of(
      view("B"),
      view("X")
    ),
    ImmutableSet.of(
      view("A"),
      view("B")
    ));

  assertEquals("Views to drop mismatch", ImmutableSet.of("A", "B", "X"), nameSet(c.getViewsToDrop()));
  assertEquals("Views to deploy mismatch", ImmutableSet.of("A", "B"), nameSet(c.getViewsToDeploy()));

  Ordering<String> dropOrder = Ordering.explicit(nameList(c.getViewsToDrop()));
  assertTrue("Must drop A before B", dropOrder.compare("A", "B") < 0);

  Ordering<String> deployOrder = Ordering.explicit(nameList(c.getViewsToDeploy()));
  assertTrue("Must deploy B before A", deployOrder.compare("B", "A") < 0);
}
 
Example 10
Project: athena   File: AlarmTableMessageHandler.java   View Source Code Vote up 5 votes
@Override
protected Collection<RequestHandler> createRequestHandlers() {
    return ImmutableSet.of(
            new AlarmTableDataRequestHandler(),
            new AlarmTableDetailRequestHandler()
    );
}
 
Example 11
Project: Reer   File: ManagedImplStructNodeInitializerExtractionStrategy.java   View Source Code Vote up 4 votes
@Override
public Iterable<ModelType<?>> supportedTypes() {
    return ImmutableSet.of();
}
 
Example 12
Project: Reer   File: WatchPointsRegistry.java   View Source Code Vote up 4 votes
public WatchPointsRegistry(boolean createNewStartingPointsUnderExistingRoots, FileSystem fileSystem) {
    this.createNewStartingPointsUnderExistingRoots = createNewStartingPointsUnderExistingRoots;
    this.fileSystem = fileSystem;
    allRequestedRoots = ImmutableSet.of();
}
 
Example 13
Project: athena   File: DefaultTopologyProviderTest.java   View Source Code Vote up 4 votes
@Override
public Iterable<Device> getDevices() {
    return ImmutableSet.of(device("a"), device("b"),
                           device("c"), device("d"),
                           device("e"), device("f"));
}
 
Example 14
Project: shuffleboard   File: SubsystemLayout.java   View Source Code Vote up 4 votes
@Override
public Set<DataType> getDataTypes() {
  return ImmutableSet.of(
      SubsystemType.Instance
  );
}
 
Example 15
Project: guava-mock   File: FuturesTest.java   View Source Code Vote up 4 votes
void assertHasImmediateCancel(
    ListenableFuture<String> a, ListenableFuture<String> b, Exception e) {
  ImmutableSet<ListenableFuture<String>> inputs = ImmutableSet.of(a, b);
  smartAssertTrue(inputs, e,
      intersect(inputs, ImmutableSet.of(doneCancelled)));
}
 
Example 16
Project: athena   File: SuppressionRulesTest.java   View Source Code Vote up 4 votes
@Before
public void setUp() throws Exception {
    rules = new SuppressionRules(ImmutableSet.of(Device.Type.ROADM, Device.Type.OTN),
                           ImmutableMap.of("no-lldp", SuppressionRules.ANY_VALUE,
                                           "sendLLDP", "false"));
}
 
Example 17
Project: guava-mock   File: SetGenerators.java   View Source Code Vote up 4 votes
@SuppressWarnings("cast")
@Override
protected Set<String> create(String[] elements) {
  return (ImmutableSet<String>) ImmutableSet.of(elements[0], elements[0]);
}
 
Example 18
Project: athena   File: ClusterViewMessageHandler.java   View Source Code Vote up 4 votes
@Override
protected Collection<RequestHandler> createRequestHandlers() {
    return ImmutableSet.of(new ClusterDataRequest());
}
 
Example 19
Project: athena   File: SfcViewMessageHandler.java   View Source Code Vote up 4 votes
@Override
protected Collection<RequestHandler> createRequestHandlers() {
    return ImmutableSet.of(new SfcDataRequest());
}
 
Example 20
Project: Telephoto   File: CommandHelper.java   View Source Code Vote up 4 votes
public void init() {
    registeredCommandMap.clear();
    lastUserCommand.clear();

    Set<Class<? extends AbstractCommand>> existsCommands = ImmutableSet.of(
            PhotoCommand.class,
            HDPhotoCommand.class,
            CameraModeCommand.class,
            CameraSettingsCommand.class,
            AlarmSettingsCommand.class,
            MinutesCommand.class,
            HistoryCommand.class,
            MotionDetectCommand.class,
            MDSensitivityCommand.class,
            MdModeCommand.class,
            ShakeSensorCommand.class,
            ShakeSensitivityCommand.class,
            GpsCommand.class,
            NotificationCommand.class,
            TtsCommand.class,
            AudioCommand.class,
            TaskerCommand.class,
            LogCommand.class,
            SetMatrixCommand.class,
            // ProCommand.class, // Temporary disable this function
            RestartCommand.class,
            TimeStatsCommand.class,
            TimeStatsClearCommand.class,
            StatusCommand.class,
            HelpCommand.class
    );

    for (Class<? extends AbstractCommand> clazz : existsCommands) {
        ICommand instance = createInstance(clazz);
        if (registeredCommandMap.containsKey(instance.getCommand())) {
            ICommand command = registeredCommandMap.get(instance.getCommand());
            L.e("Duplicate of command: " + instance.getCommand() +
                    ", names: [" + instance.getName() + ", " + command.getName() + "]");
        } else {
            registeredCommandMap.put(instance.getCommand(), instance);
        }
    }
    mainKeyboard = KeyboardUtils.getKeyboard(registeredCommandMap.values());
    L.i("Count of registered commands: " + registeredCommandMap.size());
}