Skip to content

DATAMONGO-1337 - General code quality improvements #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MongoChangeSetPersister implements ChangeSetPersister<Object> {
private static final String ENTITY_FIELD_NAME = "_entity_field_name";
private static final String ENTITY_FIELD_CLASS = "_entity_field_class";

protected final Logger log = LoggerFactory.getLogger(getClass());
private static final Logger log = LoggerFactory.getLogger(getClass());

private MongoTemplate mongoTemplate;
private EntityManagerFactory entityManagerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void append(final LoggingEvent event) {

// Copy properties into document
Map<Object, Object> props = event.getProperties();
if (null != props && props.size() > 0) {
if (null != props && !props.isEmpty()) {
BasicDBObject propsDbo = new BasicDBObject();
for (Map.Entry<Object, Object> entry : props.entrySet()) {
propsDbo.put(entry.getKey().toString(), entry.getValue().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MongoLog4jAppenderIntegrationTests {

static final String NAME = MongoLog4jAppenderIntegrationTests.class.getName();

Logger log = Logger.getLogger(NAME);
private static final Logger log = Logger.getLogger(NAME);
Mongo mongo;
DB db;
String collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected Aggregation(List<AggregationOperation> aggregationOperations) {
protected Aggregation(List<AggregationOperation> aggregationOperations, AggregationOptions options) {

Assert.notNull(aggregationOperations, "AggregationOperations must not be null!");
Assert.isTrue(aggregationOperations.size() > 0, "At least one AggregationOperation has to be provided");
Assert.isTrue(!aggregationOperations.isEmpty(), "At least one AggregationOperation has to be provided");
Assert.notNull(options, "AggregationOptions must not be null!");

this.operations = aggregationOperations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ protected String mapPropertyName(MongoPersistentProperty property) {

private static boolean isPositionalParameter(String partial) {

if (partial.equals("$")) {
if ("$".equals(partial)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Criteria is(Object o) {
}

private boolean lastOperatorWasNot() {
return this.criteria.size() > 0 && "$not".equals(this.criteria.keySet().toArray()[this.criteria.size() - 1]);
return !this.criteria.isEmpty() && "$not".equals(this.criteria.keySet().toArray()[this.criteria.size() - 1]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public abstract class AbstractMonitor {

private final Logger logger = LoggerFactory.getLogger(getClass());
private static final Logger logger = LoggerFactory.getLogger(getClass());

protected Mongo mongo;
private String username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private String prepareAndEscapeStringBeforeApplyingLikeRegex(String source, Part
return PUNCTATION_PATTERN.matcher(source).find() ? Pattern.quote(source) : source;
}

if (source.equals("*")) {
if ("*".equals(source)) {
return ".*";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@ContextConfiguration("classpath:infrastructure.xml")
public class MongoAdminIntegrationTests {

private static Log logger = LogFactory.getLog(MongoAdminIntegrationTests.class);
private static final Log logger = LogFactory.getLog(MongoAdminIntegrationTests.class);

@SuppressWarnings("unused")
private DB testAdminDb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,10 +2402,10 @@ public FooBarEnum convert(String source) {
return null;
}

if (source.equals("foo-enum-value")) {
if ("foo-enum-value".equals(source)) {
return FooBarEnum.FOO;
}
if (source.equals("bar-enum-value")) {
if ("bar-enum-value".equals(source)) {
return FooBarEnum.BAR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public void testIssue260() {

int size = 0;
for (ContentAndVersion cv : results) {
if (cv.getId().equals("Resume")) {
if ("Resume".equals(cv.getId())) {
assertEquals(6, cv.getValue().longValue());
}
if (cv.getId().equals("Schema")) {
if ("Schema".equals(cv.getId())) {
assertEquals(2, cv.getValue().longValue());
}
if (cv.getId().equals("mongoDB How-To")) {
if ("mongoDB How-To".equals(cv.getId())) {
assertEquals(2, cv.getValue().longValue());
}
size++;
Expand All @@ -141,13 +141,13 @@ public void testIssue260Part2() {
new MapReduceOptions().outputCollection("jmr2_out"), NumberAndVersion.class);
int size = 0;
for (NumberAndVersion nv : results) {
if (nv.getId().equals("1")) {
if ("1".equals(nv.getId())) {
assertEquals(2, nv.getValue().longValue());
}
if (nv.getId().equals("2")) {
if ("2".equals(nv.getId())) {
assertEquals(6, nv.getValue().longValue());
}
if (nv.getId().equals("3")) {
if ("3".equals(nv.getId())) {
assertEquals(2, nv.getValue().longValue());
}
size++;
Expand Down