@Test(expected = NullPointerException.class) public void badMerge() { DefaultAnnotations.merge(null, null); }
public static DefaultAnnotations merge(DefaultAnnotations annotations, SparseAnnotations sparseAnnotations) { checkNotNull(annotations, "Annotations cannot be null"); if (sparseAnnotations == null || sparseAnnotations.keys().isEmpty()) { return annotations; } Map<String, String> merged = copy(annotations.map); for (String key : sparseAnnotations.keys()) { if (sparseAnnotations.isRemoved(key)) { merged.remove(key); } else { merged.put(key, sparseAnnotations.value(key)); } } return new DefaultAnnotations(merged); }
DefaultAnnotations implements SparseAnnotations { public static DefaultAnnotations merge(DefaultAnnotations annotations, SparseAnnotations sparseAnnotations) { checkNotNull(annotations, "Annotations cannot be null"); if (sparseAnnotations == null || sparseAnnotations.keys().isEmpty()) { return annotations; } Map<String, String> merged = copy(annotations.map); for (String key : sparseAnnotations.keys()) { if (sparseAnnotations.isRemoved(key)) { merged.remove(key); } else { merged.put(key, sparseAnnotations.value(key)); } } return new DefaultAnnotations(merged); } }
DefaultAnnotations implements SparseAnnotations { public static DefaultAnnotations merge(DefaultAnnotations annotations, SparseAnnotations sparseAnnotations) { checkNotNull(annotations, "Annotations cannot be null"); if (sparseAnnotations == null || sparseAnnotations.keys().isEmpty()) { return annotations; } Map<String, String> merged = copy(annotations.map); for (String key : sparseAnnotations.keys()) { if (sparseAnnotations.isRemoved(key)) { merged.remove(key); } else { merged.put(key, sparseAnnotations.value(key)); } } return new DefaultAnnotations(merged); } private  DefaultAnnotations(); private  DefaultAnnotations(Map<String, String> map); }
DefaultAnnotations implements SparseAnnotations { public static DefaultAnnotations merge(DefaultAnnotations annotations, SparseAnnotations sparseAnnotations) { checkNotNull(annotations, "Annotations cannot be null"); if (sparseAnnotations == null || sparseAnnotations.keys().isEmpty()) { return annotations; } Map<String, String> merged = copy(annotations.map); for (String key : sparseAnnotations.keys()) { if (sparseAnnotations.isRemoved(key)) { merged.remove(key); } else { merged.put(key, sparseAnnotations.value(key)); } } return new DefaultAnnotations(merged); } private  DefaultAnnotations(); private  DefaultAnnotations(Map<String, String> map); @Override boolean equals(Object o); @Override int hashCode(); HashMap<String, String> asMap(); static Builder builder(); static DefaultAnnotations merge(DefaultAnnotations annotations,
                                           SparseAnnotations sparseAnnotations); static SparseAnnotations union(SparseAnnotations annotations,
                                          SparseAnnotations sparseAnnotations); @Override Set<String> keys(); @Override String value(String key); @Override boolean isRemoved(String key); @Override String toString(); }
DefaultAnnotations implements SparseAnnotations { public static DefaultAnnotations merge(DefaultAnnotations annotations, SparseAnnotations sparseAnnotations) { checkNotNull(annotations, "Annotations cannot be null"); if (sparseAnnotations == null || sparseAnnotations.keys().isEmpty()) { return annotations; } Map<String, String> merged = copy(annotations.map); for (String key : sparseAnnotations.keys()) { if (sparseAnnotations.isRemoved(key)) { merged.remove(key); } else { merged.put(key, sparseAnnotations.value(key)); } } return new DefaultAnnotations(merged); } private  DefaultAnnotations(); private  DefaultAnnotations(Map<String, String> map); @Override boolean equals(Object o); @Override int hashCode(); HashMap<String, String> asMap(); static Builder builder(); static DefaultAnnotations merge(DefaultAnnotations annotations,
                                           SparseAnnotations sparseAnnotations); static SparseAnnotations union(SparseAnnotations annotations,
                                          SparseAnnotations sparseAnnotations); @Override Set<String> keys(); @Override String value(String key); @Override boolean isRemoved(String key); @Override String toString(); static final SparseAnnotations EMPTY; }