Example usage for java.util Objects deepEquals

List of usage examples for java.util Objects deepEquals

Introduction

In this page you can find the example usage for java.util Objects deepEquals.

Prototype

public static boolean deepEquals(Object a, Object b) 

Source Link

Document

Returns true if the arguments are deeply equal to each other and false otherwise.

Usage

From source file:org.gradoop.flink.algorithms.fsm.dimspan.gspan.GSpanLogicBase.java

@Override
public PatternEmbeddingsMap growPatterns(int[] graph, PatternEmbeddingsMap parentMap,
        List<int[]> frequentPatterns, List<int[]> rightmostPaths, boolean uncompressEmbeddings,
        List<int[]> compressedPatterns) {

    PatternEmbeddingsMap childMap = PatternEmbeddingsMap.getEmptyOne();

    int minEdgeId = 0;
    int[] minExtension = new int[] { 0, 0, 0, 0, 0, 0 };

    for (int frequentPatternIndex = 0; frequentPatternIndex < frequentPatterns.size(); frequentPatternIndex++) {

        int[] compressedPattern = compressedPatterns.get(frequentPatternIndex);
        int parentPatternIndex = parentMap.getIndex(compressedPattern);

        // if frequent pattern is supported
        if (parentPatternIndex >= 0) {
            int[] parentPattern = frequentPatterns.get(frequentPatternIndex);

            if (branchConstraintEnabled) {
                int[] firstExtension = dfsCodeUtils.getBranch(parentPattern);

                if (!Objects.deepEquals(minExtension, firstExtension)) {
                    minEdgeId = graphUtils.getFirstGeqEdgeId(graph, firstExtension, minEdgeId);

                    if (minEdgeId < 0) {
                        break;
                    }/*from w  w w .j a  v  a2s  .  c  om*/

                    minExtension = firstExtension;
                }
            }

            int[] rightmostPath = rightmostPaths.get(frequentPatternIndex);

            // for each embedding
            int[][] parentEmbeddings = parentMap.getEmbeddings(parentPatternIndex, uncompressEmbeddings);

            PatternEmbeddingsMap currentParentMap = growPattern(graph, minEdgeId, parentPattern,
                    parentEmbeddings, rightmostPath);

            // add partial result to output
            childMap.append(currentParentMap);
        }
    }

    return childMap;
}

From source file:org.bremersee.common.jms.DefaultJmsConverter.java

private boolean isJson(byte[] payloadBytes) {

    if (payloadBytes == null || payloadBytes.length < (JSON_START.length + JSON_END.length)) {
        return false;
    }/*w  w w  . jav  a 2 s  .  c  om*/
    int len = payloadBytes.length;
    byte[] start = ArrayUtils.subarray(payloadBytes, 0, JSON_START.length);
    byte[] end = ArrayUtils.subarray(payloadBytes, len - JSON_END.length, len);
    return Objects.deepEquals(JSON_START, start) && Objects.deepEquals(JSON_END, end);
}

From source file:com.vmware.photon.controller.api.model.NetworkConfigurationCreateSpec.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/*from   w  ww. jav  a2s .  com*/
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    NetworkConfigurationCreateSpec other = (NetworkConfigurationCreateSpec) o;

    return Objects.equals(this.getSdnEnabled(), other.getSdnEnabled())
            && Objects.equals(this.getNetworkManagerAddress(), other.getNetworkManagerAddress())
            && Objects.equals(this.getNetworkManagerUsername(), other.getNetworkManagerUsername())
            && Objects.equals(this.getNetworkManagerPassword(), other.getNetworkManagerPassword())
            && Objects.equals(this.getNetworkZoneId(), other.getNetworkZoneId())
            && Objects.equals(this.getNetworkTopRouterId(), other.getNetworkTopRouterId())
            && Objects.equals(this.getNetworkEdgeIpPoolId(), other.getNetworkEdgeIpPoolId())
            && Objects.equals(this.getNetworkHostUplinkPnic(), other.getNetworkHostUplinkPnic())
            && Objects.equals(this.getIpRange(), other.getIpRange())
            && Objects.equals(this.getExternalIpRange(), other.getExternalIpRange())
            && Objects.deepEquals(this.getDhcpServers(), other.getDhcpServers());
}

From source file:de.bund.bfr.pmfml.sbml.PMFCompartmentImpl.java

@Override
public boolean equals(final Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;

    PMFCompartmentImpl other = (PMFCompartmentImpl) obj;

    return Objects.equals(compartment.getId(), other.compartment.getId())
            && Objects.equals(compartment.getName(), other.compartment.getName())
            && Objects.equals(pmfCode, other.pmfCode) && Objects.equals(detail, other.detail)
            && Objects.deepEquals(modelVariables, other.modelVariables);
}

From source file:info.bunji.mongodb.synces.SyncConfig.java

@Override
public boolean equals(Object other) {
    boolean ret = false;
    if (other != null && other.getClass() == getClass()) {
        SyncConfig config = (SyncConfig) other;

        if (Objects.deepEquals(importCollections, config.getImportCollections())
                && Objects.equals(mongoDbName, config.getMongoDbName())
                && Objects.equals(destDbName, config.getDestDbName())
                && Objects.deepEquals(includeFields, config.getIncludeFields())
                && Objects.deepEquals(excludeFields, config.getExcludeFields())
                && mongoConnection.equals(config.getMongoConnection())) {
            ret = true;/*from  w w w  .  j av a 2s  . c om*/
        }
    }
    return ret;
}

From source file:com.cdd.bao.importer.KeywordMapping.java

public JSONObject createAssay(JSONObject keydata, Schema schema, Map<Schema.Assignment, SchemaTree> treeCache)
        throws JSONException, IOException {
    String uniqueID = null;//from  ww  w .  j  ava 2 s .c o m
    List<String> linesTitle = new ArrayList<>(), linesBlock = new ArrayList<>();
    List<String> linesSkipped = new ArrayList<>(), linesProcessed = new ArrayList<>();
    Set<String> gotAnnot = new HashSet<>(), gotLiteral = new HashSet<>();
    JSONArray jsonAnnot = new JSONArray();
    final String SEP = "::";

    // assertions: these always supply a term
    for (Assertion asrt : assertions) {
        JSONObject obj = new JSONObject();
        obj.put("propURI", ModelSchema.expandPrefix(asrt.propURI));
        obj.put("groupNest", new JSONArray(expandPrefixes(asrt.groupNest)));
        obj.put("valueURI", ModelSchema.expandPrefix(asrt.valueURI));
        jsonAnnot.put(obj);

        String hash = asrt.propURI + SEP + asrt.valueURI + SEP
                + (asrt.groupNest == null ? "" : String.join(SEP, asrt.groupNest));
        gotAnnot.add(hash);
    }

    // go through the columns one at a time
    for (String key : keydata.keySet()) {
        String data = keydata.getString(key);

        Identifier id = findIdentifier(key);
        if (id != null) {
            if (uniqueID == null)
                uniqueID = id.prefix + data;
            continue;
        }

        TextBlock tblk = findTextBlock(key);
        if (tblk != null) {
            if (Util.isBlank(tblk.title))
                linesTitle.add(data);
            else
                linesBlock.add(tblk.title + ": " + data);
        }

        Value val = findValue(key, data);
        if (val != null) {
            if (Util.isBlank(val.valueURI)) {
                linesSkipped.add(key + ": " + data);
            } else {
                String hash = val.propURI + SEP + val.valueURI + SEP
                        + (val.groupNest == null ? "" : String.join(SEP, val.groupNest));
                if (gotAnnot.contains(hash))
                    continue;

                JSONObject obj = new JSONObject();
                obj.put("propURI", ModelSchema.expandPrefix(val.propURI));
                obj.put("groupNest", new JSONArray(expandPrefixes(val.groupNest)));
                obj.put("valueURI", ModelSchema.expandPrefix(val.valueURI));
                jsonAnnot.put(obj);
                gotAnnot.add(hash);
                linesProcessed.add(key + ": " + data);
            }
            continue;
        }

        Literal lit = findLiteral(key, data);
        if (lit != null) {
            String hash = lit.propURI + SEP + (lit.groupNest == null ? "" : String.join(SEP, lit.groupNest))
                    + SEP + data;
            if (gotLiteral.contains(hash))
                continue;

            JSONObject obj = new JSONObject();
            obj.put("propURI", ModelSchema.expandPrefix(lit.propURI));
            obj.put("groupNest", new JSONArray(expandPrefixes(lit.groupNest)));
            obj.put("valueLabel", data);
            jsonAnnot.put(obj);
            gotLiteral.add(hash);
            linesProcessed.add(key + ": " + data);

            continue;
        }

        Reference ref = findReference(key, data);
        if (ref != null) {
            Pattern ptn = Pattern.compile(ref.valueRegex);
            Matcher m = ptn.matcher(data);
            if (!m.matches() || m.groupCount() < 1)
                throw new IOException(
                        "Pattern /" + ref.valueRegex + "/ did not match '" + data + "' to produce a group.");

            JSONObject obj = new JSONObject();
            obj.put("propURI", ModelSchema.expandPrefix(ref.propURI));
            obj.put("groupNest", new JSONArray(expandPrefixes(ref.groupNest)));
            obj.put("valueLabel", ref.prefix + m.group(1));
            jsonAnnot.put(obj);
            linesProcessed.add(key + ": " + data);

            continue;
        }

        // probably shouldn't get this far, but just in case
        linesSkipped.add(key + ": " + data);
    }

    // annotation collapsing: sometimes there's a branch sequence that should exclude parent nodes
    for (int n = 0; n < jsonAnnot.length(); n++) {
        JSONObject obj = jsonAnnot.getJSONObject(n);
        String propURI = obj.getString("propURI"), valueURI = obj.optString("valueURI");
        if (valueURI == null)
            continue;
        String[] groupNest = obj.getJSONArray("groupNest").toStringArray();
        Schema.Assignment[] assnList = schema.findAssignmentByProperty(ModelSchema.expandPrefix(propURI),
                groupNest);
        if (assnList.length == 0)
            continue;
        SchemaTree tree = treeCache.get(assnList[0]);
        if (tree == null)
            continue;

        Set<String> exclusion = new HashSet<>();
        for (SchemaTree.Node node = tree.getNode(valueURI); node != null; node = node.parent)
            exclusion.add(node.uri);
        if (exclusion.size() == 0)
            continue;

        for (int i = jsonAnnot.length() - 1; i >= 0; i--)
            if (i != n) {
                obj = jsonAnnot.getJSONObject(i);
                if (!obj.has("valueURI"))
                    continue;
                if (!propURI.equals(obj.getString("propURI")))
                    continue;
                if (!Objects.deepEquals(groupNest, obj.getJSONArray("groupNest").toStringArray()))
                    continue;
                if (!exclusion.contains(obj.getString("valueURI")))
                    continue;
                jsonAnnot.remove(i);
            }
    }

    /*String text = "";
    if (linesBlock.size() > 0) text += String.join("\n", linesBlock) + "\n\n";
    if (linesSkipped.size() > 0) text += "SKIPPED:\n" + String.join("\n", linesSkipped) + "\n\n";
    text += "PROCESSED:\n" + String.join("\n", linesProcessed);*/

    List<String> sections = new ArrayList<>();
    if (linesTitle.size() > 0)
        sections.add(String.join(" / ", linesTitle));
    if (linesBlock.size() > 0)
        sections.add(String.join("\n", linesBlock));
    sections.add("#### IMPORTED ####");
    if (linesSkipped.size() > 0)
        sections.add("SKIPPED:\n" + String.join("\n", linesSkipped));
    if (linesProcessed.size() > 0)
        sections.add("PROCESSED:\n" + String.join("\n", linesProcessed));
    String text = String.join("\n\n", sections);

    JSONObject assay = new JSONObject();
    assay.put("uniqueID", uniqueID);
    assay.put("text", text);
    assay.put("schemaURI", schema.getSchemaPrefix());
    assay.put("annotations", jsonAnnot);
    return assay;
}