org.eclipse.collections.api.set.primitive.IntSet Java Examples

The following examples show how to use org.eclipse.collections.api.set.primitive.IntSet. 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: ExercisesCrud.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
@Test
public void testQ5()
{
    IntSet testIds = IntSets.immutable.of(1, 2);
    CustomerList customers = new CustomerList(CustomerFinder.customerId().in(testIds));
    this.updateCountry(customers, "UK");

    MithraManager.getInstance().clearAllQueryCaches();
    Customer c1 = CustomerFinder.findOne(CustomerFinder.customerId().eq(1));
    Customer c2 = CustomerFinder.findOne(CustomerFinder.customerId().eq(2));

    //check that the two got updated
    Assert.assertEquals("UK", c1.getCountry());
    Assert.assertEquals("UK", c2.getCountry());

    //check that nobody else got updated.
    Verify.assertSize(2, new CustomerList(CustomerFinder.country().eq("UK")));
    Verify.assertSize(3, new CustomerList(CustomerFinder.country().notEq("UK")));
}
 
Example #2
Source File: SingleColumnIntegerAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public Operation in(IntSet intSet)
{
    Operation op;
    switch (intSet.size())
    {
        case 0:
            op = new None(this);
            break;
        case 1:
            op = this.eq(intSet.intIterator().next());
            break;
        default:
            op = new IntegerInOperation(this, intSet);
            break;
    }

    return op;
}
 
Example #3
Source File: SingleColumnIntegerAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public Operation notIn(IntSet intSet)
{
    Operation op;
    switch (intSet.size())
    {
        case 0:
            op = new All(this);
            break;
        case 1:
            op = this.notEq(intSet.intIterator().next());
            break;
        default:
            op = new IntegerNotInOperation(this, intSet);
            break;
    }

    return op;
}
 
Example #4
Source File: ExercisesRelationships.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
@Test
    public void testQ5()
    {
        IntSet accountIds = IntSets.immutable.of(1, 2, 999);
        CustomerList customers = getCustomers(accountIds);
        Verify.assertSize(2, customers);

        int dbHitsBefore = MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount();
        // Try un-commenting the following lines, running the test, and then
        // look at the debug messages output.
//        System.out.println("No more SQL SELECT after this point ...");
//        customers.getCustomerAt(0).getAccounts().size();
//        System.out.println("----====----");
//        customers.getCustomerAt(1).getAccounts().size();
//        System.out.println("----====****====----");
        Assert.assertEquals(dbHitsBefore, MithraManagerProvider.getMithraManager().getDatabaseRetrieveCount());
    }
 
Example #5
Source File: AbstractNonDatedCache.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public List get(int indexRef, IntSet intSetIndexValues)
{
    Index index = indices[indexRef - 1];
    MithraFastList result = new MithraFastList(this.getAverageReturnSize(index, intSetIndexValues.size()));
    IntIterator it = intSetIndexValues.intIterator();
    this.readWriteLock.acquireReadLock();
    try
    {
        while (it.hasNext())
        {
            addAllListToList(wrapObjectInList(index.get(it.next())), result);
        }
        return result;
    }
    finally
    {
        this.readWriteLock.release();
    }
}
 
Example #6
Source File: CalculatedIntegerAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public Operation notIn(IntSet set)
{
    Operation op;
    switch (set.size())
    {
        case 0:
            op = new All(this);
            break;
        case 1:
            op = this.notEq(set.intIterator().next());
            break;
        default:
            op = new IntegerNotInOperation(this, set);
            break;
    }

    return op;
}
 
Example #7
Source File: CalculatedIntegerAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public Operation in(IntSet set)
{
    Operation op;
    switch (set.size())
    {
        case 0:
            op = new None(this);
            break;
        case 1:
            op = this.eq(set.intIterator().next());
            break;
        default:
            op = new IntegerInOperation(this, set);
            break;
    }

    return op;
}
 
Example #8
Source File: ExercisesCrud.java    From reladomo-kata with Apache License 2.0 5 votes vote down vote up
@Test
public void testQ11()
{
    int sizeBefore = CustomerFinder.findMany(CustomerFinder.all()).size();
    IntSet customerIds = IntSets.immutable.of(1, 2);
    deleteCustomers(customerIds);

    int sizeAfter = CustomerFinder.findMany(CustomerFinder.all()).size();
    Assert.assertEquals(-2, sizeAfter - sizeBefore);
}
 
Example #9
Source File: IntegerAttribute.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 IntExtractor integerExtractor = (IntExtractor) extractor;
    final IntSet set = asSet(objects, integerExtractor);
    return this.in(set);
}
 
Example #10
Source File: IntegerAttribute.java    From reladomo with Apache License 2.0 4 votes vote down vote up
private IntSet asSet(List objects, IntExtractor integerExtractor)
{
    return this.asSet(objects, integerExtractor, new IntHashSet());
}
 
Example #11
Source File: MappedIntegerAttribute.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public Operation in(IntSet intSet)
{
    return new MappedOperation(this.mapper, this.wrappedAttribute.in(intSet));
}
 
Example #12
Source File: MappedIntegerAttribute.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public Operation notIn(IntSet intSet)
{
    return new MappedOperation(this.mapper, this.wrappedAttribute.notIn(intSet));
}
 
Example #13
Source File: AbstractDatedCache.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public List get(int indexRef, IntSet intSetIndexValues)
{
    throw new RuntimeException("not supported");
}
 
Example #14
Source File: ExercisesCrud.java    From reladomo-kata with Apache License 2.0 4 votes vote down vote up
public void deleteCustomers(IntSet customers)
{
    Assert.fail("Implement this functionality to make the test pass");
}
 
Example #15
Source File: TypedCache.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public List get(int indexRef, IntSet intSetIndexValues)
{
    return this.filterByType(this.cache.get(indexRef, intSetIndexValues));
}
 
Example #16
Source File: IntegerAttribute.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public abstract Operation notIn(IntSet intSet);
 
Example #17
Source File: ConstantIntSet.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public IntSet select(IntPredicate predicate)
{
    return delegate.select(predicate);
}
 
Example #18
Source File: ConstantIntSet.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public IntSet reject(IntPredicate predicate)
{
    return delegate.reject(predicate);
}
 
Example #19
Source File: ConstantIntSet.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public IntSet freeze()
{
    return this;
}
 
Example #20
Source File: IntegerInOperation.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public IntegerInOperation(IntegerAttribute attribute, IntSet intSet)
{
    super(attribute);
    this.set = intSet.freeze();
}
 
Example #21
Source File: IntegerNotInOperation.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public IntegerNotInOperation(IntegerAttribute attribute, IntSet intSet)
{
    super(attribute);
    this.set = intSet.freeze();
}
 
Example #22
Source File: ExercisesRelationships.java    From reladomo-kata with Apache License 2.0 4 votes vote down vote up
public CustomerList getCustomers(IntSet customerIds)
{
    Assert.fail("Implement this functionality to make the test pass");
    return null;
}
 
Example #23
Source File: IntegerAttribute.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
public abstract Operation in(IntSet intSet);
 
Example #24
Source File: Cache.java    From reladomo with Apache License 2.0 votes vote down vote up
List get(int indexRef, IntSet intSetIndexValues); 
Example #25
Source File: IntegerAttribute.java    From reladomo with Apache License 2.0 votes vote down vote up
Operation<Owner> in(IntSet intSet); 
Example #26
Source File: IntegerAttribute.java    From reladomo with Apache License 2.0 votes vote down vote up
Operation<Owner> notIn(IntSet intSet);