-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove last instance of Filter.encode()
implement $mod's codec
- Loading branch information
1 parent
168ea9a
commit 2dfa71b
Showing
18 changed files
with
143 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/src/main/java/dev/morphia/mapping/codec/ModFilterCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.morphia.mapping.codec; | ||
|
||
import dev.morphia.MorphiaDatastore; | ||
import dev.morphia.mapping.codec.filters.BaseFilterCodec; | ||
import dev.morphia.query.filters.ModFilter; | ||
|
||
import org.bson.BsonWriter; | ||
import org.bson.codecs.EncoderContext; | ||
|
||
import static dev.morphia.mapping.codec.CodecHelper.array; | ||
import static dev.morphia.mapping.codec.CodecHelper.document; | ||
import static dev.morphia.mapping.codec.CodecHelper.unnamedValue; | ||
|
||
public class ModFilterCodec extends BaseFilterCodec<ModFilter> { | ||
public ModFilterCodec(MorphiaDatastore datastore) { | ||
super(datastore); | ||
} | ||
|
||
@Override | ||
public void encode(BsonWriter writer, ModFilter filter, EncoderContext context) { | ||
document(writer, filter.path(datastore.getMapper()), () -> { | ||
array(writer, filter.getName(), () -> { | ||
unnamedValue(writer, datastore, filter.divisor(), context); | ||
unnamedValue(writer, datastore, filter.remainder(), context); | ||
}); | ||
}); | ||
} | ||
|
||
@Override | ||
public Class<ModFilter> getEncoderClass() { | ||
return ModFilter.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.