@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof SelfDescribingObject)) { return false; } SelfDescribingObject rhs = (SelfDescribingObject) obj; return Objects.equals(_name, rhs._name) && _schema.equals(rhs._schema) && Objects.equals(_value, rhs._value); }
@SuppressWarnings({"rawtypes", "unchecked"}) private @Nonnull Comparator<?> schemaComparator(Schema schema) { if (schema.equals(Schema.ACL_TRACE)) { return COMPARATOR_ACL_TRACE; } else if (schema.equals(Schema.BOOLEAN)) { return naturalOrder(); } else if (schema.equals(Schema.DOUBLE)) { return naturalOrder(); } else if (schema.equals(Schema.FLOW)) { return naturalOrder(); } else if (schema.equals(Schema.FLOW_TRACE)) { return naturalOrder(); } else if (schema.equals(Schema.INTEGER)) { return naturalOrder(); } else if (schema.equals(Schema.INTERFACE)) { return naturalOrder(); } else if (schema.equals(Schema.IP)) { return naturalOrder(); } else if (schema.equals(Schema.ISSUE)) { return comparing(Issue::getSeverity); } else if (schema.getType() == Type.LIST) { Comparator schemaComparator = schemaComparator(schema.getInnerSchema()); return lexicographical(nullsFirst(schemaComparator)); } else if (schema.equals(Schema.LONG)) { return naturalOrder(); } else if (schema.equals(Schema.NODE)) { return COMPARATOR_NODE; } else if (schema.equals(Schema.PREFIX)) { return naturalOrder(); } else if (schema.getType() == Type.SET) {
if (targetSchema.equals(Schema.STRING) && outputPropertyValue != null && !(outputPropertyValue instanceof String)) { outputPropertyValue = outputPropertyValue.toString(); } else if ((targetSchema.equals(Schema.list(Schema.STRING)) || targetSchema.equals(Schema.set(Schema.STRING))) && outputPropertyValue != null && outputPropertyValue instanceof Collection<?>) {
@VisibleForTesting static @Nonnull Map<String, MajorIssueConfig> computeMajorIssueConfigs(TableAnswerElement table) { Map<String, ImmutableList.Builder<MinorIssueConfig>> majorIssueConfigs = new HashMap<>(); // For every issue column of every row, extract the issue and use it to update the map table.getMetadata().getColumnMetadata().stream() .filter(c -> c.getSchema().equals(Schema.ISSUE)) .map(ColumnMetadata::getName) .flatMap( column -> table.getRowsList().stream() .filter(row -> row.hasNonNull(column)) .map(row -> row.getIssue(column))) .forEach( issue -> majorIssueConfigs .computeIfAbsent(issue.getType().getMajor(), m -> ImmutableList.builder()) .add( new MinorIssueConfig( issue.getType().getMinor(), issue.getSeverity(), issue.getUrl()))); return CommonUtil.toImmutableMap( majorIssueConfigs, Entry::getKey, // major issue type e -> new MajorIssueConfig(e.getKey(), e.getValue().build())); }
Set<String> issueColumns = tableMetadata.getColumnMetadata().stream() .filter(cm -> cm.getSchema().equals(Schema.ISSUE)) .map(ColumnMetadata::getName) .collect(ImmutableSet.toImmutableSet());