Skip to content

Commit

Permalink
formatting and variable name changes from CR
Browse files Browse the repository at this point in the history
  • Loading branch information
suryagaddipati committed May 16, 2016
1 parent 4df72b5 commit 027bf81
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main/java/com/groupon/jenkins/mongo/CauseActionConverter.java
Expand Up @@ -36,32 +36,33 @@ of this software and associated documentation files (the "Software"), to deal


public class CauseActionConverter extends TypeConverter implements SimpleValueConverter { public class CauseActionConverter extends TypeConverter implements SimpleValueConverter {


public CauseActionConverter(){ public CauseActionConverter() {
super(CauseAction.class); super(CauseAction.class);
} }


@Override @Override
public CauseAction decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) { public CauseAction decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
if(fromDBObject == null) return null; if (fromDBObject == null) return null;


List causes = new ArrayList(); List causes = new ArrayList();
List rawList = (List) ((DBObject) fromDBObject).get("causes"); List rawList = (List) ((DBObject) fromDBObject).get("causes");
for(Object obj : rawList) { for (Object obj : rawList) {
DBObject dbObj = (DBObject) obj; DBObject dbObj = (DBObject) obj;
causes.add(getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache())); Object cause = getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache());
causes.add(cause);
} }
return new CauseAction(causes); return new CauseAction(causes);
} }


@Override @Override
public Object encode(Object value, MappedField optionalExtraInfo) { public Object encode(Object value, MappedField optionalExtraInfo) {
if(value == null) return null; if (value == null) return null;
CauseAction action = (CauseAction) value; CauseAction action = (CauseAction) value;
List core = new BasicDBList(); List causes = new BasicDBList();


for(Object obj : action.getCauses()) { for (Object obj : action.getCauses()) {
core.add(getMapper().toDBObject(obj)); causes.add(getMapper().toDBObject(obj));
} }
return BasicDBObjectBuilder.start("causes",core).add("className",CauseAction.class.getName()).get(); return BasicDBObjectBuilder.start("causes", causes).add("className", CauseAction.class.getName()).get();
} }
} }

0 comments on commit 027bf81

Please sign in to comment.