Skip to content

Commit 7d22016

Browse files
committed
Fix styles.
1 parent befbde2 commit 7d22016

4 files changed

Lines changed: 49 additions & 16 deletions

File tree

bson/src/main/org/bson/codecs/pojo/ConventionAnnotationImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ private <T> void processCreatorAnnotation(final ClassModelBuilder<T> classModelB
170170
}
171171

172172
if (propertyModelBuilder == null) {
173-
propertyModelBuilder = addCreatorPropertyToClassModelBuilder(classModelBuilder, bsonProperty.value(), parameterType);
173+
propertyModelBuilder = addCreatorPropertyToClassModelBuilder(classModelBuilder, bsonProperty.value(),
174+
parameterType);
174175
} else {
175176
// An existing property is found, set its write name
176177
propertyModelBuilder.writeName(bsonProperty.value());
@@ -186,10 +187,11 @@ private <T> void processCreatorAnnotation(final ClassModelBuilder<T> classModelB
186187
}
187188
}
188189

189-
private <T, S> PropertyModelBuilder<S> addCreatorPropertyToClassModelBuilder(final ClassModelBuilder<T> classModelBuilder, final String name,
190-
final Class<S> clazz) {
191-
PropertyModelBuilder<S> propertyModelBuilder = createPropertyModelBuilder(new PropertyMetadata<S>(name, classModelBuilder.getType().getSimpleName(),
192-
TypeData.builder(clazz).build())).readName(null).writeName(name);
190+
private <T, S> PropertyModelBuilder<S> addCreatorPropertyToClassModelBuilder(final ClassModelBuilder<T> classModelBuilder,
191+
final String name,
192+
final Class<S> clazz) {
193+
PropertyModelBuilder<S> propertyModelBuilder = createPropertyModelBuilder(new PropertyMetadata<S>(name,
194+
classModelBuilder.getType().getSimpleName(), TypeData.builder(clazz).build())).readName(null).writeName(name);
193195
classModelBuilder.addProperty(propertyModelBuilder);
194196
return propertyModelBuilder;
195197
}

bson/src/main/org/bson/codecs/pojo/InstanceCreatorImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.bson.codecs.pojo;
1818

1919
import org.bson.codecs.configuration.CodecConfigurationException;
20-
import org.bson.codecs.pojo.annotations.BsonProperty;
2120

2221
import java.util.HashMap;
2322
import java.util.Map;

bson/src/test/unit/org/bson/codecs/pojo/entities/conventions/CreatorConstructorIdModel.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2017 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.bson.codecs.pojo.entities.conventions;
218

319
import org.bson.codecs.pojo.annotations.BsonCreator;
@@ -13,7 +29,7 @@ public class CreatorConstructorIdModel {
1329
public long longField;
1430

1531
@BsonCreator
16-
public CreatorConstructorIdModel(@BsonId String id, @BsonProperty("integersField") final List<Integer> integerField,
32+
public CreatorConstructorIdModel(final @BsonId String id, @BsonProperty("integersField") final List<Integer> integerField,
1733
@BsonProperty("longField") final long longField) {
1834
this.id = id;
1935
this.integersField = integerField;
@@ -52,7 +68,7 @@ public void setLongField(final long longField) {
5268
}
5369

5470
@Override
55-
public boolean equals(Object o) {
71+
public boolean equals(final Object o) {
5672
if (this == o) {
5773
return true;
5874
}
@@ -68,8 +84,8 @@ public boolean equals(Object o) {
6884
if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null) {
6985
return false;
7086
}
71-
if (getIntegersField() != null ? !getIntegersField().equals(that.getIntegersField()) :
72-
that.getIntegersField() != null) {
87+
if (getIntegersField() != null ? !getIntegersField().equals(that.getIntegersField())
88+
: that.getIntegersField() != null) {
7389
return false;
7490
}
7591
return getStringField() != null ? getStringField().equals(that.getStringField()) : that.getStringField() == null;
@@ -86,11 +102,11 @@ public int hashCode() {
86102

87103
@Override
88104
public String toString() {
89-
return "CreatorConstructorIdModel{" +
90-
"id='" + id + '\'' +
91-
", integersField=" + integersField +
92-
", stringField='" + stringField + '\'' +
93-
", longField=" + longField +
94-
'}';
105+
return "CreatorConstructorIdModel{"
106+
+ "id='" + id + '\''
107+
+ ", integersField=" + integersField
108+
+ ", stringField='" + stringField + '\''
109+
+ ", longField=" + longField
110+
+ '}';
95111
}
96112
}

bson/src/test/unit/org/bson/codecs/pojo/entities/conventions/CreatorConstructorRenameModel.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2017 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.bson.codecs.pojo.entities.conventions;
218

319
import org.bson.codecs.pojo.annotations.BsonCreator;

0 commit comments

Comments
 (0)