-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds readName test about single discriminator serialization
- Loading branch information
1 parent
2baf3f5
commit 8eeeac9
Showing
2 changed files
with
77 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
bson/src/test/unit/org/bson/codecs/pojo/entities/DiscriminatorWithProperty.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,51 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.bson.codecs.pojo.entities; | ||
|
||
import org.bson.codecs.pojo.annotations.BsonDiscriminator; | ||
import org.bson.codecs.pojo.annotations.BsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
@BsonDiscriminator(key = "discriminatorKey", value = "discriminatorValue") | ||
public class DiscriminatorWithProperty { | ||
|
||
public DiscriminatorWithProperty() { | ||
} | ||
|
||
@BsonProperty("discriminatorKey") | ||
public String getDiscriminator() { | ||
return "discriminatorValue"; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final DiscriminatorWithProperty that = (DiscriminatorWithProperty) o; | ||
return Objects.equals(getDiscriminator(), that.getDiscriminator()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(getDiscriminator()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DiscriminatorWithProperty{}"; | ||
} | ||
} |