@Test(expected = IllegalStateException.class) public void addConflictingFields1() { MongoMapping mapping = new MongoMapping(); mapping.addClassField("classFieldName", "top1", "int32"); mapping.addClassField("classFieldName", "top1.l2", "double"); }
public void addClassField(String classFieldName, String docFieldName, String fieldType) { try { newDocumentField(docFieldName, valueOf(fieldType.toUpperCase(Locale.getDefault()))); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Declared '" + fieldType + "' for class field '" + classFieldName + "' is not supported by MongoMapping"); } if (classToDocument.containsKey(classFieldName)) { if (!classToDocument.get(classFieldName).equals(docFieldName)) { throw new IllegalStateException("The class field '" + classFieldName + "' is already registered in the mapping" + " with the document field '" + classToDocument.get(classFieldName) + " which differs from the new one '" + docFieldName + "'."); } } else { classToDocument.put(classFieldName, docFieldName); documentToClass.put(docFieldName, classFieldName); } }
MongoMapping { public void addClassField(String classFieldName, String docFieldName, String fieldType) { try { newDocumentField(docFieldName, valueOf(fieldType.toUpperCase(Locale.getDefault()))); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Declared '" + fieldType + "' for class field '" + classFieldName + "' is not supported by MongoMapping"); } if (classToDocument.containsKey(classFieldName)) { if (!classToDocument.get(classFieldName).equals(docFieldName)) { throw new IllegalStateException("The class field '" + classFieldName + "' is already registered in the mapping" + " with the document field '" + classToDocument.get(classFieldName) + " which differs from the new one '" + docFieldName + "'."); } } else { classToDocument.put(classFieldName, docFieldName); documentToClass.put(docFieldName, classFieldName); } } }
MongoMapping { public void addClassField(String classFieldName, String docFieldName, String fieldType) { try { newDocumentField(docFieldName, valueOf(fieldType.toUpperCase(Locale.getDefault()))); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Declared '" + fieldType + "' for class field '" + classFieldName + "' is not supported by MongoMapping"); } if (classToDocument.containsKey(classFieldName)) { if (!classToDocument.get(classFieldName).equals(docFieldName)) { throw new IllegalStateException("The class field '" + classFieldName + "' is already registered in the mapping" + " with the document field '" + classToDocument.get(classFieldName) + " which differs from the new one '" + docFieldName + "'."); } } else { classToDocument.put(classFieldName, docFieldName); documentToClass.put(docFieldName, classFieldName); } }  }
MongoMapping { public void addClassField(String classFieldName, String docFieldName, String fieldType) { try { newDocumentField(docFieldName, valueOf(fieldType.toUpperCase(Locale.getDefault()))); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Declared '" + fieldType + "' for class field '" + classFieldName + "' is not supported by MongoMapping"); } if (classToDocument.containsKey(classFieldName)) { if (!classToDocument.get(classFieldName).equals(docFieldName)) { throw new IllegalStateException("The class field '" + classFieldName + "' is already registered in the mapping" + " with the document field '" + classToDocument.get(classFieldName) + " which differs from the new one '" + docFieldName + "'."); } } else { classToDocument.put(classFieldName, docFieldName); documentToClass.put(docFieldName, classFieldName); } }  void renameCollection(String oldName, String newName); String getCollectionName(); void setCollectionName(String collName); void addClassField(String classFieldName,
      String docFieldName, String fieldType); String getDocumentField(String field); }
MongoMapping { public void addClassField(String classFieldName, String docFieldName, String fieldType) { try { newDocumentField(docFieldName, valueOf(fieldType.toUpperCase(Locale.getDefault()))); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Declared '" + fieldType + "' for class field '" + classFieldName + "' is not supported by MongoMapping"); } if (classToDocument.containsKey(classFieldName)) { if (!classToDocument.get(classFieldName).equals(docFieldName)) { throw new IllegalStateException("The class field '" + classFieldName + "' is already registered in the mapping" + " with the document field '" + classToDocument.get(classFieldName) + " which differs from the new one '" + docFieldName + "'."); } } else { classToDocument.put(classFieldName, docFieldName); documentToClass.put(docFieldName, classFieldName); } }  void renameCollection(String oldName, String newName); String getCollectionName(); void setCollectionName(String collName); void addClassField(String classFieldName,
      String docFieldName, String fieldType); String getDocumentField(String field); static final Logger LOG; }