3636import java .util .Collections ;
3737import java .util .Comparator ;
3838import java .util .HashMap ;
39+ import java .util .Iterator ;
3940import java .util .List ;
4041import java .util .Locale ;
4142import java .util .Map ;
@@ -862,9 +863,35 @@ protected Content buildResultTable() {
862863 return section ;
863864 }
864865
865- private static final Content CHECK = HtmlTree .SPAN (Entity .CHECK ).setClass ("same" );
866- private static final Content CROSS = HtmlTree .SPAN (Entity .CROSS ).setClass ("diff" );
867- private static final Content SINGLE = HtmlTree .SPAN (Entity .CIRCLED_DIGIT_ONE ).setClass ("single" );
866+ // The following names are intended to be "semantic" or "abstract" names,
867+ // distinct from the concrete representations used in the generated documentation.
868+ // The names are intentionally different from any corresponding entity names.
869+
870+ /**
871+ * Used when two elements compare as equal.
872+ */
873+ // possible alternatives: Entity.CHECK
874+ private static final Content SAME = HtmlTree .SPAN (Entity .EQUALS ).setClass ("same" );
875+ /**
876+ * Used when two elements compare as not equal.
877+ */
878+ // possible alternatives: Entity.CROSS
879+ private static final Content DIFFERENT = HtmlTree .SPAN (Entity .NE ).setClass ("diff" );
880+ /**
881+ * Used when an element does not appear in all instances of the APIs being compared.
882+ * See also {@link #ADDED}, {@link #REMOVED}.
883+ */
884+ private static final Content PARTIAL = HtmlTree .SPAN (Entity .CIRCLED_DIGIT_ONE ).setClass ("partial" );
885+ /**
886+ * Used in a 2-way comparison when it is determined that an element has been added.
887+ */
888+ // possible alternatives: '>' (for example, as used in text diff tools) or other right-pointing arrows
889+ private static final Content ADDED = HtmlTree .SPAN (Entity .PLUS ).setClass ("partial" );
890+ /**
891+ * Used in a 2-way comparison when it is determined that an element has been removed.
892+ */
893+ // possible alternatives: '<' (for example, as used in text diff tools) or other left-pointing arrows
894+ private static final Content REMOVED = HtmlTree .SPAN (Entity .MINUS ).setClass ("partial" );
868895
869896
870897 protected Content getResultGlyph (ElementKey eKey ) {
@@ -882,19 +909,36 @@ protected Content getResultGlyph(Position pos, APIMap<?> map) {
882909 return Text .of ("?" );
883910 }
884911 if (map .size () == 1 ) {
885- return SINGLE ;
912+ API api = map .keySet ().iterator ().next ();
913+ Set <API > apis = parent .apis ;
914+ if (apis .size () == 2 ) {
915+ // The following assumes an ordering on the order in which the
916+ // APIs were defined on the command line: older first, newer second
917+ Iterator <API > iter = apis .iterator ();
918+ API oldAPI = iter .next ();
919+ API newAPI = iter .next ();
920+ if (api == oldAPI ) { // and not in new API
921+ return REMOVED ;
922+ } else if (api == newAPI ) { // and not in old API
923+ return ADDED ;
924+ } else {
925+ // should not happen?
926+ return PARTIAL ;
927+ }
928+ }
929+ return PARTIAL ;
886930 }
887931 Boolean eq = results .get (pos );
888- return (eq == null ) ? SINGLE : eq ? CHECK : CROSS ;
932+ return (eq == null ) ? PARTIAL : eq ? SAME : DIFFERENT ;
889933 }
890934
891935 // TODO: improve abstraction; these args are typically reversed
892936 protected Content getResultGlyph (APIMap <?> map , Position pos ) {
893937 if (map .size () == 1 ) {
894- return SINGLE ;
938+ return PARTIAL ;
895939 }
896940 Boolean eq = results .get (pos );
897- return (eq == null ) ? SINGLE : eq ? CHECK : CROSS ;
941+ return (eq == null ) ? PARTIAL : eq ? SAME : DIFFERENT ;
898942 }
899943
900944 protected APIMap <? extends Element > getElementMap (ElementKey eKey ) {
0 commit comments