Java Code Examples for org.eclipse.collections.impl.set.mutable.UnifiedSet#add()

The following examples show how to use org.eclipse.collections.impl.set.mutable.UnifiedSet#add() . 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: NonPrimitiveAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Override
public Operation in(final List objects, final Extractor extractor)
{
    final UnifiedSet set = new UnifiedSet();
    for (int i = 0, n = objects.size(); i < n; i++)
    {
        final Object o = extractor.valueOf(objects.get(i));
        if (o != null)
        {
            set.add(o);
        }
    }
    return this.in(set);
}
 
Example 2
Source File: NonPrimitiveAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Override
public Operation in(final Iterable objects, final Extractor extractor)
{
    final UnifiedSet set = new UnifiedSet();
    for (Object object : objects)
    {
        final Object o = extractor.valueOf(object);
        if (o != null)
        {
            set.add(o);
        }
    }
    return this.in(set);
}
 
Example 3
Source File: MultiEqualityMapper.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public Set<Attribute> getAllLeftAttributes()
{
    fixLeftAttributes();
    UnifiedSet result = new UnifiedSet(this.leftAttributes.length);
    for(int i=0;i<this.leftAttributes.length;i++) result.add(this.leftAttributes[i]);
    return result;
}
 
Example 4
Source File: TransitivePropagator.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void addEquality(ObjectWithMapperStack<Attribute> left, ObjectWithMapperStack<Attribute> right)
{
    UnifiedSet<ObjectWithMapperStack<Attribute>> existing = this.getEqualityMap().get(left);
    if (existing == null)
    {
        existing = new UnifiedSet<ObjectWithMapperStack<Attribute>>(2);
        this.getEqualityMap().put(left, existing);
    }
    existing.add(right);
}
 
Example 5
Source File: TestMariaGeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for (int i = 0; i < 1000000; i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for (int i = 0; i < 10000; i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 6
Source File: TestRelationships.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testOverSpecifiedWithSetParameter()
{
    OrderItem item = OrderItemFinder.findOne(OrderItemFinder.id().eq(1));

    UnifiedSet descriptions = new UnifiedSet();
    descriptions.add("foo");
    descriptions.add("bar");

    assertNull(item.getOverSpecifiedOrder(descriptions));

    descriptions.add("First order");
    assertNotNull(item.getOverSpecifiedOrder(descriptions));
    assertEquals(1, item.getOverSpecifiedOrder(descriptions).getOrderId());
}
 
Example 7
Source File: TestOracleGeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for(int i=0;i<1000000;i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for(int i=0;i<10000;i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 8
Source File: TestPostgresGeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for (int i = 0; i < 1000000; i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for (int i = 0; i < 10000; i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 9
Source File: StringSourceFullCacheLoader.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public List<Operation> getOperationsForFullCacheLoad(RelatedFinder finder)
{
    UnifiedSet<String> set = new UnifiedSet<String>();
    set.add("A");
    set.add("B");
    Operation op = ((StringAttribute) finder.getSourceAttribute()).in(set);
    if (finder.getAsOfAttributes() != null)
    {
        for(AsOfAttribute a: finder.getAsOfAttributes())
        {
            op = op.and(a.equalsEdgePoint());
        }
    }
    return ListFactory.create(op);
}
 
Example 10
Source File: TestDb2GeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for(int i=0;i<1000000;i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for(int i=0;i<10000;i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 11
Source File: TestMsSqlGeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for(int i=0;i<1000000;i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for(int i=0;i<10000;i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 12
Source File: TestSybaseGeneralTestCases.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testTempTableNamer()
{
    String first = TempTableNamer.getNextTempTableName();
    for(int i=0;i<1000000;i++)
    {
        assertFalse(first.equals(TempTableNamer.getNextTempTableName()));
    }
    UnifiedSet set = new UnifiedSet(10000);
    for(int i=0;i<10000;i++)
    {
        String s = TempTableNamer.getNextTempTableName();
        assertFalse(set.contains(s));
        set.add(s);
    }
}
 
Example 13
Source File: TestDeDupedDualMessagingAdapter.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeDupe()
{
    UnifiedSet<String> messageSet1 = UnifiedSet.newSetWith("msg1", "msg2", "msg3");
    UnifiedSet<String> messageSet2 = UnifiedSet.newSetWith("msg4");
    UnifiedSet<String> messageSet3 = UnifiedSet.newSetWith("msg5");

    //simulate message consumption by injecting messages into the adapter
    //set1 is consumed by both the the adapters
    factory1.getAdapter().inject(messageSet1);
    factory2.getAdapter().inject(messageSet1);

    //set2 is consumed just by adapter1
    factory1.getAdapter().inject(messageSet2);

    //set3 is consumed just by adapter2
    factory2.getAdapter().inject(messageSet3);

    //the actual event handler gets a unique set
    FastList<String> expectedMessages = FastList.newList();
    expectedMessages.addAll(messageSet1);
    expectedMessages.addAll(messageSet2);
    expectedMessages.addAll(messageSet3);

    List<MessageWithSubject> receivedMessages = recordingHandler.getMessages();
    UnifiedSet<String> receivedMessageSubjects = UnifiedSet.newSet();
    UnifiedSet<String> receivedMessageBodies = UnifiedSet.newSet();

    for (MessageWithSubject pair : receivedMessages)
    {
        receivedMessageSubjects.add(pair.getSubject());
        receivedMessageBodies.add(new String(pair.getMessage()));
    }

    assertTrue(receivedMessageBodies.containsAll(expectedMessages));
    assertEquals(1, receivedMessageSubjects.size());
    assertEquals(TEST_SUBJECT, receivedMessageSubjects.getFirst());
}
 
Example 14
Source File: TestTablePartitionManager.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testExpectedTablesAreCreated() throws Exception
{
    Set<String> createdTables = ConnectionManagerForTestsWithTableManager.getInstance().getCreatedTables();

    UnifiedSet<String> expectedTables = UnifiedSet.newSet();

    for(MithraRuntimeCacheController controller : MithraManager.getInstance().getConfigManager().getRuntimeCacheControllerSet())
    {
        String table = controller.getFinderInstanceFromFinderClass().getMithraObjectPortal().getDatabaseObject().getDefaultTableName();

        if(controller.getFinderInstanceFromFinderClass().getSourceAttributeType() == null )
        {
            expectedTables.add(ConnectionManagerForTestsWithTableManager.getInstance().getTableName(table));
        }
        else if(controller.getFinderInstanceFromFinderClass().getSourceAttributeType().isIntSourceAttribute())
        {
            expectedTables.add(ConnectionManagerForTestsWithTableManager.getInstance().getTableName(table, 0));
            expectedTables.add(ConnectionManagerForTestsWithTableManager.getInstance().getTableName(table, 1));
        }
        else
        {
            expectedTables.add(ConnectionManagerForTestsWithTableManager.getInstance().getTableName(table, "A"));
            expectedTables.add(ConnectionManagerForTestsWithTableManager.getInstance().getTableName(table, "B"));
        }
    }

    assertEquals( expectedTables, createdTables );
}
 
Example 15
Source File: ConvertContainerToAnother.java    From tutorials with MIT License 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static List convertToList() {
    UnifiedSet<String> cars = new UnifiedSet<>();

    cars.add("Toyota");
    cars.add("Mercedes");
    cars.add("Volkswagen");

    return cars.toList();
}
 
Example 16
Source File: EqualityMapper.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public Set<Attribute> getAllLeftAttributes()
{
    UnifiedSet set = new UnifiedSet(1); // this has to be a modifiable set.
    set.add(this.left);
    return set;
}