@Override public int compareTo(Span o) { if(context != null && o.getContext() != null && !context.equals(o.getContext())){ log.warn("Comparing Spans with different Context. This is not an " + "intended usage of this class as start|end|type parameters " + "do not have a natural oder over different texts."); log.info("This will sort Spans based on start|end|type parameters "+ "regardless that the might be over different texts!"); //TODO consider throwing an IllegalStateExcetion! } //Compare Integers ASC (used here three times) // (x < y) ? -1 : ((x == y) ? 0 : 1); int start = (span[0] < o.getStart()) ? -1 : ((span[0] == o.getStart()) ? 0 : 1); if(start == 0){ //sort end in DESC order int end = (span[1] < o.getEnd()) ? 1 : ((span[1] == o.getEnd()) ? 0 : -1); //if start AND end is the same compare based on the span type //Natural order of span types is defined by the Enum.ordinal() int o1 = getType().ordinal(); int o2 = o.getType().ordinal(); return end != 0 ? end : (o1 < o2) ? -1 : ((o1 == o2) ? 0 : 1); } else { return start; } }
@Override public int compareTo(Span o) { if(context != null && o.getContext() != null && !context.equals(o.getContext())){ log.warn("Comparing Spans with different Context. This is not an " + "intended usage of this class as start|end|type parameters " + "do not have a natural oder over different texts."); log.info("This will sort Spans based on start|end|type parameters "+ "regardless that the might be over different texts!"); //TODO consider throwing an IllegalStateExcetion! } //Compare Integers ASC (used here three times) // (x < y) ? -1 : ((x == y) ? 0 : 1); int start = (span[0] < o.getStart()) ? -1 : ((span[0] == o.getStart()) ? 0 : 1); if(start == 0){ //sort end in DESC order int end = (span[1] < o.getEnd()) ? 1 : ((span[1] == o.getEnd()) ? 0 : -1); //if start AND end is the same compare based on the span type //Natural order of span types is defined by the Enum.ordinal() int o1 = getType().ordinal(); int o2 = o.getType().ordinal(); return end != 0 ? end : (o1 < o2) ? -1 : ((o1 == o2) ? 0 : 1); } else { return start; } }
Object value; if(parser != null){ value = parser.parse(jValue, span.getContext()); } else { JsonNode valueNode = jValue.path("value");
Object value; if(parser != null){ value = parser.parse(jValue, span.getContext()); } else { JsonNode valueNode = jValue.path("value");