Example usage for java.util Objects hashCode

List of usage examples for java.util Objects hashCode

Introduction

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

Prototype

public static int hashCode(Object o) 

Source Link

Document

Returns the hash code of a non- null argument and 0 for a null argument.

Usage

From source file:com.offbynull.voip.kademlia.model.Id.java

@Override
public int hashCode() {
    int hash = 3;
    hash = 31 * hash + Objects.hashCode(this.bitString);
    return hash;
}

From source file:mx.edu.um.mateo.inventario.model.Entrada.java

@Override
public int hashCode() {
    int hash = 7;
    hash = 23 * hash + Objects.hashCode(this.id);
    hash = 23 * hash + Objects.hashCode(this.version);
    hash = 23 * hash + Objects.hashCode(this.folio);
    return hash;/*from   w ww  .  j a  v  a2  s  . c  o m*/
}

From source file:mx.edu.um.mateo.general.model.Usuario.java

@Override
public int hashCode() {
    int hash = 5;
    hash = 97 * hash + Objects.hashCode(this.id);
    hash = 97 * hash + Objects.hashCode(this.version);
    hash = 97 * hash + Objects.hashCode(this.username);
    return hash;/* ww  w  .  j a  va  2  s .com*/
}

From source file:com.buffalokiwi.aerodrome.jet.products.ShippingExceptionRec.java

@Override
public int hashCode() {
    int hash = 7;
    hash = 53 * hash + Objects.hashCode(this.serviceLevel);
    hash = 53 * hash + Objects.hashCode(this.shippingMethod);
    hash = 53 * hash + Objects.hashCode(this.overrideType);
    hash = 53 * hash + Objects.hashCode(this.shippingChargeAmount);
    hash = 53 * hash + Objects.hashCode(this.shippingExceptionType);
    return hash;//ww w .  jav a 2  s  .  co m
}

From source file:com.offbynull.peernetic.common.identification.Id.java

@Override
public int hashCode() {
    int hash = 5;
    hash = 89 * hash + Objects.hashCode(this.data);
    return hash;
}

From source file:org.createnet.raptor.models.objects.ServiceObject.java

@Override
public int hashCode() {
    int hash = 7;
    hash = 53 * hash + Objects.hashCode(this.id);
    return hash;
}

From source file:fr.landel.utils.assertor.OperatorTest.java

/**
 * Test method for {@link Operator#and()}.
 *//*  ww w.  j a  v a  2  s.  c  om*/
@Test
public void testAnd() {
    final String text = "text";
    assertTrue(Assertor.that(text).isNotEmpty().and().isNotBlank().isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(true).isTrue().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(true).isFalse().isOK());

    assertTrue(
            Assertor.that(text).isNotEmpty().and(text.getClass()).isAssignableFrom(CharSequence.class).isOK());
    assertFalse(
            Assertor.that(text).isNotEmpty().and(text.getClass()).isAssignableFrom(StringBuilder.class).isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(Calendar.getInstance())
            .isAfter(DateUtils.getCalendar(new Date(0))).isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Calendar.getInstance())
            .isBefore(DateUtils.getCalendar(new Date(0))).isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(new Date()).isAfter(new Date(0)).isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(new Date()).isBefore(new Date(0)).isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(LocalDateTime.now()).isAfter(LocalDateTime.MIN).isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(LocalDateTime.now()).isAfter(LocalDateTime.MAX).isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(2).isGT(1).isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(2).isLT(1).isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and("tt").isNotEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and("tt").isEmpty().isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(new String[] {}).isEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(new String[] {}).isNotEmpty().isOK());
    assertTrue(Assertor.that(text).isNotEmpty().and(new String[] {}, EnumAnalysisMode.STREAM).isEmpty().isOK());
    assertFalse(
            Assertor.that(text).isNotEmpty().and(new String[] {}, EnumAnalysisMode.STREAM).isNotEmpty().isOK());
    assertTrue(
            Assertor.that(text).isNotEmpty().and(new String[] {}, EnumAnalysisMode.PARALLEL).isEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(new String[] {}, EnumAnalysisMode.PARALLEL).isNotEmpty()
            .isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyList()).isEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyList()).isNotEmpty().isOK());
    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyList(), EnumAnalysisMode.STREAM).isEmpty()
            .isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyList(), EnumAnalysisMode.STREAM)
            .isNotEmpty().isOK());
    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyList(), EnumAnalysisMode.PARALLEL)
            .isEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyList(), EnumAnalysisMode.PARALLEL)
            .isNotEmpty().isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyMap()).isEmpty().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyMap()).isNotEmpty().isOK());
    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyMap(), EnumAnalysisMode.STREAM).isEmpty()
            .isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyMap(), EnumAnalysisMode.STREAM)
            .isNotEmpty().isOK());
    assertTrue(Assertor.that(text).isNotEmpty().and(Collections.emptyMap(), EnumAnalysisMode.PARALLEL).isEmpty()
            .isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(Collections.emptyMap(), EnumAnalysisMode.PARALLEL)
            .isNotEmpty().isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and((Object) 0).isNotNull().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and((Object) 0).isNull().isOK());

    assertTrue(Assertor.that(text).isNotEmpty().and(new Exception()).isNotNull().isOK());
    assertFalse(Assertor.that(text).isNotEmpty().and(new Exception()).isNull().isOK());

    assertFalse(Assertor.that(Color.BLACK).isNull().and().isEqual(Color.black).isOK());
    assertFalse(Assertor.that(Color.BLACK).isNull().and((Object) 0).isNotNull().isOK());

    // SUB

    assertTrue(Assertor.that(true).isTrue().and(Assertor.that("text").isEmpty().or().contains("e")).isOK());
    // left part error
    assertEquals("the boolean should be false", Assertor.that(true).isFalse()
            .and(Assertor.that("text").isEmpty().or().contains("e")).getErrors().get());
    // right part error
    assertEquals("(the char sequence 'text' should contain 's')",
            Assertor.that(true).isTrue().and(Assertor.that("text").contains("s")).getErrors().get());
    assertFalse(Assertor.that(true).isTrue().and(Assertor.that("text").contains("s")).isOK());
    assertTrue(Assertor.that(true).isTrue().or(Assertor.that("text").contains("s")).isOK());
    assertFalse(Assertor.that(true).isTrue().or(Assertor.that("text").contains("s")).getErrors().isPresent());
    // both parts error
    assertEquals("the boolean should be false", Assertor.that(true).isFalse()
            .and(Assertor.that("text").isEmpty().or().contains("s")).getErrors().get());
    assertEquals("the combination 'true' and ' NAND ' is invalid", Assertor.that(true).isTrue()
            .nand(Assertor.that("text").isEmpty().or().contains("s")).getErrors().get());
    assertEquals("the boolean should be false OR (the char sequence 'text' should contain 's')", Assertor
            .that(true).isFalse().or(Assertor.that("text").isNotEmpty().and().contains("s")).getErrors().get());
    // precondition error
    assertEquals("the char sequence cannot be null and the searched substring cannot be null or empty",
            Assertor.that(true).isTrue().and(Assertor.that("text").contains((String) null)).getErrors().get());

    // SUB ASSERTOR

    assertTrue(Assertor.that(text).isNotEmpty().andAssertor(t -> Assertor.that(t.length()).isGT(3)).isOK());
    // left part error
    assertEquals("the char sequence 'text' should be null or empty", Assertor.that(text).isEmpty()
            .andAssertor(t -> Assertor.that(t.length()).isGT(4)).getErrors().get());
    // right part error
    assertEquals("(the number '4' should be greater than '4')", Assertor.that(text).isNotEmpty()
            .andAssertor(t -> Assertor.that(t.length()).isGT(4)).getErrors().get());
    // precondition error
    assertEquals("the char sequence cannot be null and the searched substring cannot be null or empty",
            Assertor.that(text).isNotEmpty()
                    .andAssertor(t -> Assertor.that(t.substring(0)).contains((String) null)).getErrors().get());
    // null
    assertFalse(Assertor.that((String) null).isEmpty().andAssertor(t -> {
        if (t != null) {
            return Assertor.that(t.substring(1)).contains("e");
        } else {
            return Assertor.that((String) null).isNull();
        }
    }).getErrors().isPresent());

    assertException(
            () -> Assertor.that(text).isNotEmpty()
                    .andAssertor((Function<String, StepCharSequence<String>>) null).isOK(),
            IllegalStateException.class, "sub assertor cannot be null");

    // MAPPER

    assertTrue(Assertor.that(true).isTrue().andObject(b -> b.toString()).hasHashCode(Objects.hashCode("true"))
            .isOK());
    assertTrue(Assertor.that(true).isTrue().andCharSequence(b -> b.toString()).contains("ue").isOK());
    assertTrue(Assertor.that("test").isNotEmpty()
            .andArray(s -> ArrayUtils.toObject(s.getBytes(StandardCharsets.UTF_8))).contains((byte) 'e')
            .isOK());
    assertTrue(Assertor.that(true).isTrue().andBoolean(b -> !b).isFalse().isOK());
    assertTrue(Assertor.that(true).isTrue().andClass(b -> b.getClass()).hasSimpleName("Boolean").isOK());
    assertTrue(Assertor.that(true).isTrue().andDate(b -> new Date(1464475553641L))
            .isAfter(new Date(1464475553640L)).isOK());
    assertTrue(Assertor.that(true).isTrue().andCalendar(b -> DateUtils.getCalendar(new Date(1464475553641L)))
            .isBefore(Calendar.getInstance()).isOK());
    assertTrue(
            Assertor.that(true).isTrue().andTemporal(b -> DateUtils.getLocalDateTime(new Date(1464475553641L)))
                    .isBefore(LocalDateTime.now()).isOK());
    assertTrue(Assertor.that(true).isTrue().andEnum(b -> EnumOperator.AND).hasName("AND").isOK());
    assertTrue(Assertor.that(true).isTrue().andIterable(b -> Arrays.asList('t', 'r')).contains('t').isOK());
    assertTrue(Assertor.that(true).isTrue().andMap(b -> MapUtils2.newHashMap("key", b)).contains("key", true)
            .isOK());
    assertTrue(Assertor.that(true).isTrue().andNumber(b -> b.hashCode()).isGT(0).isOK()); // 1231
    assertTrue(Assertor.that(true).isTrue().andThrowable(b -> new IOException(b.toString()))
            .validates(e -> e.getMessage().contains("true")).isOK());
}

From source file:benedict.zhang.addon.roleplaying.model.SpellConfiguration.java

@Override
public int hashCode() {
    int hash = 5;
    hash = 89 * hash + Objects.hashCode(this.spellName);
    return hash;
}

From source file:org.kontalk.model.KonMessage.java

@Override
public int hashCode() {
    int hash = 7;
    hash = 67 * hash + Objects.hashCode(this.mDir);
    hash = 67 * hash + Objects.hashCode(this.mJID);
    hash = 67 * hash + Objects.hashCode(this.mXMPPID);
    hash = 67 * hash + Objects.hashCode(this.mDate);
    return hash;/*  w  w  w  .  j  a v  a2  s . c  o m*/
}

From source file:com.hurence.logisland.connect.source.KafkaConnectStreamSource.java

@Override
public Dataset<Row> getBatch(Option<Offset> start, Offset end) {
    Long startOff = start.isDefined() ? Long.parseLong(start.get().json())
            : !bufferedRecords.isEmpty() ? bufferedRecords.firstKey() : 0L;

    Map<Integer, List<InternalRow>> current = new LinkedHashMap<>(
            bufferedRecords.subMap(startOff, Long.parseLong(end.json()) + 1)).keySet().stream()
                    .flatMap(offset -> {
                        List<Tuple2<SourceTask, SourceRecord>> srl = bufferedRecords.remove(offset);
                        if (srl != null) {
                            uncommittedRecords.put(offset, srl);
                            return srl.stream();
                        }//from w  ww.j a  v a2  s  .  c  om
                        return Stream.empty();
                    }).map(Tuple2::_2).map(
                            sourceRecord -> InternalRow.fromSeq(JavaConversions
                                    .<Object>asScalaBuffer(Arrays.asList(toUTFString(sourceRecord.topic()),
                                            toUTFString(sourceRecord.sourcePartition()),
                                            toUTFString(sourceRecord.sourceOffset()),
                                            keyConverter.fromConnectData(sourceRecord.topic(),
                                                    sourceRecord.keySchema(), sourceRecord.key()),
                                            valueConverter.fromConnectData(sourceRecord.topic(),
                                                    sourceRecord.valueSchema(), sourceRecord.value())))
                                    .toSeq()))
                    .collect(Collectors.groupingBy(row -> Objects.hashCode((row.getString(1)))));
    return sparkPlatform.createStreamingDataFrame(sqlContext, new SimpleRDD(sqlContext.sparkContext(), current),
            DATA_SCHEMA);

}