MongoDBUpdate { @Nonnull public <E> MongoDBUpdate setAllExcept( @Nonnull final EntityMapper<E> mapper, @Nonnull final E entity, @Nonnull final EntityMapper<E>.Field<?>... fields) throws MapperException { assert mapper != null; assert entity != null; assert fields != null; final Set<EntityMapper<E>.Field<?>> fieldSet = new HashSet<>(Arrays.asList(fields)); for (final EntityMapper<E>.Field<?> field : mapper.getSubMapper( entity.getClass()).getFieldsIncludingSuperEntities()) { if (!fieldSet.contains(field)) { if (!field.getFieldName().equals(MongoDBKeyNames.ID_KEY)) { final DBObject dbObject = mapper.toDb(entity); assert dbObject != null; final Object value = dbObject.get(field.getFieldName()); if (value != null) { modifiers.add(new Modifier(OPERATOR_SET, mongoPath(field)) { @Nullable @Override Object toDBValue() { return value; } }); } else { modifiers.add(new Modifier(OPERATOR_UNSET, mongoPath(field)) { @Nullable @Override Object toDBValue() { return 1; } }); } } } } return this; }  @Nonnull MongoDBUpdate set(
            @Nonnull final EntityMapper<?>.Field<T> f0,
            @Nullable final T value); @Nonnull MongoDBUpdate set(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<T> f1,
            @Nullable final T value); @Nonnull MongoDBUpdate set(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<T> f2,
            @Nullable final T value); @Nonnull MongoDBUpdate set(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<T> f3,
            @Nullable final T value); @Nonnull MongoDBUpdate setAllExcept(
            @Nonnull final EntityMapper<E> mapper,
            @Nonnull final E entity,
            @Nonnull final EntityMapper<E>.Field<?>... fields); @Nonnull MongoDBUpdate setRaw(
            @Nonnull final String fieldName,
            @Nullable final T value); @Nonnull MongoDBUpdate setRaw(
            @Nonnull final String fieldName,
            @Nonnull final Mapper<T> mapper,
            @Nullable final T value); @Nonnull MongoDBUpdate unset(@Nonnull final EntityMapper<?>.Field<?>... fs); @Nonnull MongoDBUpdate push(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            @Nullable final T value); @Nonnull MongoDBUpdate push(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1,
            @Nullable final T value); @Nonnull MongoDBUpdate push(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2,
            @Nullable final T value); @Nonnull MongoDBUpdate push(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3,
            @Nullable final T value); @Nonnull MongoDBUpdate pushAll(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            final Collection<T> values); @Nonnull MongoDBUpdate pushAll(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1,
            final Collection<T> values); @Nonnull MongoDBUpdate pushAll(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2,
            final Collection<T> values); @Nonnull MongoDBUpdate pushAll(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3,
            final Collection<T> values); @Nonnull MongoDBUpdate pull(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            @Nullable final T value); @Nonnull MongoDBUpdate pull(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1,
            @Nullable final T value); @Nonnull MongoDBUpdate pull(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2,
            @Nullable final T value); @Nonnull MongoDBUpdate pull(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            @Nonnull final MongoDBQuery mongoDBQuery); @Nonnull MongoDBUpdate pull(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3,
            @Nullable final T value); @Nonnull MongoDBUpdate popFirst(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0); @Nonnull MongoDBUpdate popFirst(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1); @Nonnull MongoDBUpdate popFirst(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2); @Nonnull MongoDBUpdate popFirst(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3); @Nonnull MongoDBUpdate popLast(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0); @Nonnull MongoDBUpdate popLast(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1); @Nonnull MongoDBUpdate popLast(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2); @Nonnull MongoDBUpdate popLast(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3); @Nonnull MongoDBUpdate inc(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            @Nullable final T value); @Nonnull MongoDBUpdate inc(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1,
            @Nullable final T value); @Nonnull MongoDBUpdate inc(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2,
            @Nullable final T value); @Nonnull MongoDBUpdate inc(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3,
            @Nullable final T value); @Nonnull MongoDBUpdate addToSet(
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f0,
            @Nullable final T value); @Nonnull MongoDBUpdate addToSet(
            @Nonnull final HasFieldName f0,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f1,
            @Nullable final T value); @Nonnull MongoDBUpdate addToSet(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f2,
            @Nullable final T value); @Nonnull MongoDBUpdate addToSet(
            @Nonnull final HasFieldName f0,
            @Nonnull final HasFieldName f1,
            @Nonnull final HasFieldName f2,
            @Nonnull final EntityMapper<?>.Field<Collection<T>> f3,
            @Nullable final T value); @Nonnull DBObject toDBObject(); @Override String toString(); static final String OPERATOR_SET; static final String OPERATOR_UNSET; static final String OPERATOR_PUSH; static final String OPERATOR_PUSH_ALL; static final String OPERATOR_PULL; static final String OPERATOR_POP_FIRST; static final String OPERATOR_POP_LAST; static final String OPERATOR_INC; static final String OPERATOR_ADD_TO_SET; }
@Test public void testSetAllExcept() throws MapperException, SchemaException { LOG.info("testSetAllExcept"); final TestMapperRegistry testMapperRegistry = new TestMapperRegistry(); final TestEntityMapper testEntityMapper = testMapperRegistry.getMapper(TestEntityMapper.class); final TestEntity testEntity = new TestEntity(new Uid<>(), "field0", "field1", "field2", "field3", "field4"); final MongoDBUpdate mongoDBUpdate0 = new MongoDBUpdate().setAllExcept(testEntityMapper, testEntity, testEntityMapper.f4); final BasicDBObject value0 = (BasicDBObject) mongoDBUpdate0.toDBObject().get(MongoDBUpdate.OPERATOR_SET); Assert.assertNotNull(value0); Assert.assertEquals(4, value0.size()); final MongoDBUpdate mongoDBUpdate1 = new MongoDBUpdate().setAllExcept(testEntityMapper, testEntity, testEntityMapper.f3, testEntityMapper.f4); final BasicDBObject value1 = (BasicDBObject) mongoDBUpdate1.toDBObject().get(MongoDBUpdate.OPERATOR_SET); Assert.assertNotNull(value1); Assert.assertEquals(3, value1.size()); final MongoDBUpdate mongoDBUpdate2 = new MongoDBUpdate().setAllExcept(testEntityMapper, testEntity); final BasicDBObject value2 = (BasicDBObject) mongoDBUpdate2.toDBObject().get(MongoDBUpdate.OPERATOR_SET); Assert.assertNotNull(value2); Assert.assertEquals(5, value2.size()); final MongoDBUpdate mongoDBUpdate3 = new MongoDBUpdate().setAllExcept(testEntityMapper, testEntity, testEntityMapper.f0, testEntityMapper.f1, testEntityMapper.f2, testEntityMapper.f3, testEntityMapper.f4); final BasicDBObject value3 = (BasicDBObject) mongoDBUpdate3.toDBObject(); Assert.assertNotNull(value3); Assert.assertEquals(0, value3.size()); }