Example usage for java.util Arrays deepEquals

List of usage examples for java.util Arrays deepEquals

Introduction

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

Prototype

public static boolean deepEquals(Object[] a1, Object[] a2) 

Source Link

Document

Returns true if the two specified arrays are deeply equal to one another.

Usage

From source file:org.apache.eagle.alert.engine.model.StreamEvent.java

@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }//from w  ww.j  a  va  2  s .com
    if (obj instanceof StreamEvent) {
        StreamEvent another = (StreamEvent) obj;
        return Objects.equals(this.streamId, another.streamId) && this.timestamp == another.timestamp
                && Arrays.deepEquals(this.data, another.data)
                && Objects.equals(this.metaVersion, another.metaVersion);
    }
    return false;
}

From source file:com.opengamma.analytics.financial.provider.curve.SingleCurveBundle.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//from  w ww.j av  a2 s. c om
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof SingleCurveBundle)) {
        return false;
    }
    final SingleCurveBundle<?> other = (SingleCurveBundle<?>) obj;
    if (_size != other._size) {
        return false;
    }
    if (!ObjectUtils.equals(_curveName, other._curveName)) {
        return false;
    }
    if (!Arrays.equals(_startingPoints, other._startingPoints)) {
        return false;
    }
    if (!Arrays.deepEquals(_derivatives, other._derivatives)) {
        return false;
    }
    if (!ObjectUtils.equals(_curveGenerator, other._curveGenerator)) {
        return false;
    }
    return true;
}

From source file:org.apache.mahout.df.mapred.partial.PartialBuilderTest.java

public void testProcessOutput() throws Exception {
    JobConf job = new JobConf();
    job.setNumMapTasks(numMaps);//from   w ww. j  a v  a  2s.co m

    Random rng = RandomUtils.getRandom();

    // prepare the output
    TreeID[] keys = new TreeID[numTrees];
    MapredOutput[] values = new MapredOutput[numTrees];
    int[] firstIds = new int[numMaps];
    randomKeyValues(rng, keys, values, firstIds);

    // store the output in a sequence file
    Path base = getTestTempDirPath("testdata");
    FileSystem fs = base.getFileSystem(job);

    Path outputFile = new Path(base, "PartialBuilderTest.seq");
    Writer writer = SequenceFile.createWriter(fs, job, outputFile, TreeID.class, MapredOutput.class);

    for (int index = 0; index < numTrees; index++) {
        writer.append(keys[index], values[index]);
    }
    writer.close();

    // load the output and make sure its valid
    TreeID[] newKeys = new TreeID[numTrees];
    Node[] newTrees = new Node[numTrees];

    PartialBuilder.processOutput(job, base, firstIds, newKeys, newTrees, new TestCallback(keys, values));

    // check the forest
    for (int tree = 0; tree < numTrees; tree++) {
        assertEquals(values[tree].getTree(), newTrees[tree]);
    }

    assertTrue("keys not equal", Arrays.deepEquals(keys, newKeys));
}

From source file:org.apache.mahout.df.mapreduce.partial.PartialBuilderTest.java

public void testProcessOutput() throws Exception {
    Configuration conf = new Configuration();
    conf.setInt("mapred.map.tasks", numMaps);

    Random rng = RandomUtils.getRandom();

    // prepare the output
    TreeID[] keys = new TreeID[numTrees];
    MapredOutput[] values = new MapredOutput[numTrees];
    int[] firstIds = new int[numMaps];
    randomKeyValues(rng, keys, values, firstIds);

    // store the output in a sequence file
    Path base = getTestTempDirPath("testdata");
    FileSystem fs = base.getFileSystem(conf);

    Path outputFile = new Path(base, "PartialBuilderTest.seq");
    Writer writer = SequenceFile.createWriter(fs, conf, outputFile, TreeID.class, MapredOutput.class);

    for (int index = 0; index < numTrees; index++) {
        writer.append(keys[index], values[index]);
    }//from w  w  w.j a  v a2  s  . c o  m
    writer.close();

    // load the output and make sure its valid
    TreeID[] newKeys = new TreeID[numTrees];
    Node[] newTrees = new Node[numTrees];

    PartialBuilder.processOutput(new Job(conf), base, firstIds, newKeys, newTrees,
            new TestCallback(keys, values));

    // check the forest
    for (int tree = 0; tree < numTrees; tree++) {
        assertEquals(values[tree].getTree(), newTrees[tree]);
    }

    assertTrue("keys not equal", Arrays.deepEquals(keys, newKeys));
}

From source file:com.hpcloud.mon.app.command.CreateMetricCommand.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    CreateMetricCommand other = (CreateMetricCommand) obj;
    if (dimensions == null) {
        if (other.dimensions != null)
            return false;
    } else if (!dimensions.equals(other.dimensions))
        return false;
    if (name == null) {
        if (other.name != null)
            return false;
    } else if (!name.equals(other.name))
        return false;
    // Note - Deep Equals is used here
    if (!Arrays.deepEquals(timeValues, other.timeValues))
        return false;
    if (timestamp != other.timestamp)
        return false;
    if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value))
        return false;
    return true;//from w  ww. j av a2 s.  c om
}

From source file:com.hpcloud.mon.common.model.metric.Metric.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Metric other = (Metric) obj;//ww  w .j av a  2  s  .co m
    if (dimensions == null) {
        if (other.dimensions != null)
            return false;
    } else if (!dimensions.equals(other.dimensions))
        return false;
    if (name == null) {
        if (other.name != null)
            return false;
    } else if (!name.equals(other.name))
        return false;
    // Note - Deep Equals is used here
    if (!Arrays.deepEquals(timeValues, other.timeValues))
        return false;
    if (timestamp != other.timestamp)
        return false;
    if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value))
        return false;
    return true;
}

From source file:monasca.common.model.metric.Metric.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (!(obj instanceof Metric))
        return false;
    Metric other = (Metric) obj;//from  w  w  w. j a  v  a2  s .  co m
    if (definition == null) {
        if (other.definition != null)
            return false;
    } else if (!definition.equals(other.definition))
        return false;
    if (dimensions == null) {
        if (other.dimensions != null)
            return false;
    } else if (!dimensions.equals(other.dimensions))
        return false;
    if (name == null) {
        if (other.name != null)
            return false;
    } else if (!name.equals(other.name))
        return false;
    if (!Arrays.deepEquals(timeValues, other.timeValues))
        return false;
    if (timestamp != other.timestamp)
        return false;
    if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value))
        return false;
    return true;
}

From source file:org.protempa.valueset.ValueSetElementBuilder.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//  ww  w  .ja va 2s  .co  m
    if (getClass() != obj.getClass()) {
        return false;
    }
    final ValueSetElementBuilder other = (ValueSetElementBuilder) obj;
    if (!Objects.equals(this.valueBuilder, other.valueBuilder)) {
        return false;
    }
    if (!Objects.equals(this.displayName, other.displayName)) {
        return false;
    }
    if (!Objects.equals(this.abbrevDisplayName, other.abbrevDisplayName)) {
        return false;
    }
    if (!Arrays.deepEquals(this.attributeBuilders, other.attributeBuilders)) {
        return false;
    }
    return true;
}

From source file:org.alfresco.util.exec.RuntimeExecBeansTest.java

public void testSplitArguments() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);
    try {//w w  w. j a v a  2  s . co  m
        RuntimeExec splitExec = (RuntimeExec) ctx.getBean("commandSplitArguments");
        assertNotNull(splitExec);
        String[] splitCommand = splitExec.getCommand();
        assertTrue("Command arguments not split into 'dir', '.' and '..' :" + Arrays.deepToString(splitCommand),
                Arrays.deepEquals(new String[] { "dir", ".", ".." }, splitCommand));
    } finally {
        ctx.close();
    }
}

From source file:com.github.horrorho.inflatabledonkey.cloud.cloudkit.CKInit.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//w  ww . j a v a  2s .com
    if (getClass() != obj.getClass()) {
        return false;
    }
    final CKInit other = (CKInit) obj;
    if (!Objects.equals(this.cloudKitDeviceUrl, other.cloudKitDeviceUrl)) {
        return false;
    }
    if (!Objects.equals(this.cloudKitDatabaseUrl, other.cloudKitDatabaseUrl)) {
        return false;
    }
    if (!Arrays.deepEquals(this.containers, other.containers)) {
        return false;
    }
    if (!Objects.equals(this.cloudKitShareUrl, other.cloudKitShareUrl)) {
        return false;
    }
    if (!Objects.equals(this.cloudKitUserId, other.cloudKitUserId)) {
        return false;
    }
    return true;
}