/** Tests the hash code computation. */
  @Test
  public void testHashCode() {
    final CitationImpl citation = new CitationImpl();
    final PropertyAccessor accessor = createPropertyAccessor(citation);
    int hashCode = accessor.hashCode(citation);
    assertEquals("Empty metadata.", 0, hashCode);

    final String ISBN = "Dummy ISBN";
    citation.setISBN(ISBN);
    hashCode = accessor.hashCode(citation);
    assertEquals("Metadata with a single String value.", ISBN.hashCode(), hashCode);

    final Set<Object> set = new HashSet<Object>();
    assertEquals("By Set.hashCode() contract.", 0, set.hashCode());
    assertTrue(set.add(ISBN));
    assertEquals("Expected Metadata.hashCode() == Set.hashCode().", set.hashCode(), hashCode);

    final InternationalString title = new SimpleInternationalString("Dummy title");
    citation.setTitle(title);
    hashCode = accessor.hashCode(citation);
    assertEquals("Metadata with two values.", ISBN.hashCode() + title.hashCode(), hashCode);
    assertTrue(set.add(title));
    assertEquals("Expected Metadata.hashCode() == Set.hashCode().", set.hashCode(), hashCode);
    assertEquals("CitationsImpl.hashCode() should delegate.", hashCode, citation.hashCode());

    final Collection<Object> values = citation.asMap().values();
    assertEquals(hashCode, new HashSet<Object>(values).hashCode());
    assertTrue(values.containsAll(set));
    assertTrue(set.containsAll(values));
  }
Пример #2
0
 // 用Eclipse自动生成
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((matches == null) ? 0 : matches.hashCode());
   result = prime * result + ((unmatches == null) ? 0 : unmatches.hashCode());
   return result;
 }
Пример #3
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((devices == null) ? 0 : devices.hashCode());
   result = prime * result + ((links == null) ? 0 : links.hashCode());
   return result;
 }
Пример #4
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = prime + ((baseConstraints == null) ? 0 : baseConstraints.hashCode());
   result = prime * result + ((complexConstraints == null) ? 0 : complexConstraints.hashCode());
   result = prime * result + ((pointsToSets == null) ? 0 : pointsToSets.hashCode());
   result = prime * result + ((simpleConstraints == null) ? 0 : simpleConstraints.hashCode());
   return result;
 }
Пример #5
0
 @Override
 public int hashCode() {
   int result = statuses.hashCode();
   result = 31 * result + headers.hashCode();
   result = 31 * result + contentTypes.hashCode();
   result = 31 * result + entityTypes.hashCode();
   result = 31 * result + inlineEntities.hashCode();
   return result;
 }
Пример #6
0
 @Override
 public int hashCode() {
   int result = includes != null ? includes.hashCode() : 0;
   result = 31 * result + (excludes != null ? excludes.hashCode() : 0);
   result = 31 * result + (includeSpecs != null ? includeSpecs.hashCode() : 0);
   result = 31 * result + (excludeSpecs != null ? excludeSpecs.hashCode() : 0);
   result = 31 * result + (caseSensitive ? 1 : 0);
   return result;
 }
 @Override
 public int hashCode() {
   int result = osPs != null ? osPs.hashCode() : 0;
   result = 31 * result + (osUs != null ? osUs.hashCode() : 0);
   result = 31 * result + (beginRange != null ? beginRange.hashCode() : 0);
   result = 31 * result + (endRange != null ? endRange.hashCode() : 0);
   result = 31 * result + (beginInclusive ? 1 : 0);
   result = 31 * result + (endInclusive ? 1 : 0);
   result = 31 * result + (parents != null ? parents.hashCode() : 0);
   return result;
 }
  protected PentahoCompiledPermissionsImpl getCompiledPermissions(Set<Principal> principals)
      throws RepositoryException {
    // check the cache first
    if (compiledPermissionsCache.containsKey(principals.hashCode()))
      return compiledPermissionsCache.get(principals.hashCode());

    PentahoCompiledPermissionsImpl compiledPermissions =
        new PentahoCompiledPermissionsImpl(principals, session, entryCollector, this, true);
    compiledPermissionsCache.put(principals.hashCode(), compiledPermissions);
    return compiledPermissions;
  }
Пример #9
0
 @Override
 public int hashCode() {
   int result = (int) (versionCreated ^ (versionCreated >>> 32));
   result = 31 * result + (int) (versionUpdated ^ (versionUpdated >>> 32));
   result = 31 * result + (type != null ? type.hashCode() : 0);
   result = 31 * result + (updatedFields != null ? updatedFields.hashCode() : 0);
   result = 31 * result + (recordTypeChanged ? 1 : 0);
   result = 31 * result + (vtagsToIndex != null ? vtagsToIndex.hashCode() : 0);
   result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
   return result;
 }
Пример #10
0
 @Override
 public int hashCode() {
   int result;
   result = name.hashCode();
   result = 31 * result + (type != null ? type.hashCode() : 0);
   result = 31 * result + compilerClasspath.hashCode();
   result = 31 * result + classes.hashCode();
   result = 31 * result + javadoc.hashCode();
   result = 31 * result + sources.hashCode();
   return result;
 }
Пример #11
0
 @Override
 public int hashCode() {
   int result = _specification.hashCode();
   result = 31 * result + (_value != null ? _value.hashCode() : 0);
   result = 31 * result + (_result != null ? _result.hashCode() : 0);
   result = 31 * result + (_exceptionClass != null ? _exceptionClass.hashCode() : 0);
   result = 31 * result + (_exceptionMsg != null ? _exceptionMsg.hashCode() : 0);
   result = 31 * result + (_stackTrace != null ? _stackTrace.hashCode() : 0);
   result = 31 * result + (_missingInputs != null ? _missingInputs.hashCode() : 0);
   result = 31 * result + (_originalRequirements != null ? _originalRequirements.hashCode() : 0);
   return result;
 }
Пример #12
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result =
       prime * result + ((colaboradorenderecos == null) ? 0 : colaboradorenderecos.hashCode());
   result = prime * result + ((descricao == null) ? 0 : descricao.hashCode());
   result = prime * result + ((estado == null) ? 0 : estado.hashCode());
   result = prime * result + ((filials == null) ? 0 : filials.hashCode());
   result = prime * result + ((munCodigo == null) ? 0 : munCodigo.hashCode());
   return result;
 }
Пример #13
0
 @Override
 public int hashCode() {
   int result = eventCode != null ? eventCode.hashCode() : 0;
   result = 31 * result + (eventTypeCodes != null ? eventTypeCodes.hashCode() : 0);
   result = 31 * result + (eventActionCode != null ? eventActionCode.hashCode() : 0);
   result = 31 * result + (eventOutcome != null ? eventOutcome.hashCode() : 0);
   result = 31 * result + (eventDateTime != null ? eventDateTime.hashCode() : 0);
   result = 31 * result + (participants != null ? participants.hashCode() : 0);
   result = 31 * result + (sources != null ? sources.hashCode() : 0);
   result = 31 * result + (objects != null ? objects.hashCode() : 0);
   return result;
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = super.hashCode();
   result = prime * result + (approved ? 1231 : 1237);
   result = prime * result + ((authorities == null) ? 0 : authorities.hashCode());
   result = prime * result + ((extensions == null) ? 0 : extensions.hashCode());
   result = prime * result + ((redirectUri == null) ? 0 : redirectUri.hashCode());
   result = prime * result + ((resourceIds == null) ? 0 : resourceIds.hashCode());
   result = prime * result + ((responseTypes == null) ? 0 : responseTypes.hashCode());
   return result;
 }
Пример #15
0
 @Test
 public void testEquals() throws Exception {
   Set<Object> control = new HashSet<Object>();
   assertTrue(set.equals(control));
   assertEquals(control.hashCode(), set.hashCode());
   for (int i = 0; i < 50; i++) {
     int n = random.nextInt();
     set.add(n);
     control.add(n);
   }
   assertTrue(set.equals(control));
   assertEquals(control.hashCode(), set.hashCode());
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = super.hashCode();
   result = prime * result + ((description == null) ? 0 : description.hashCode());
   result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
   result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode());
   result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode());
   result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
   result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
   result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
   result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
   return result;
 }
Пример #17
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((bigDecimalAttribute == null) ? 0 : bigDecimalAttribute.hashCode());
   result = prime * result + ((integerSetAttribute == null) ? 0 : integerSetAttribute.hashCode());
   result = prime * result + (int) (key ^ (key >>> 32));
   long temp;
   temp = Double.doubleToLongBits(rangeKey);
   result = prime * result + (int) (temp ^ (temp >>> 32));
   result = prime * result + ((stringAttribute == null) ? 0 : stringAttribute.hashCode());
   result = prime * result + ((stringSetAttribute == null) ? 0 : stringSetAttribute.hashCode());
   result = prime * result + ((version == null) ? 0 : version.hashCode());
   return result;
 }
  protected void byteArrayEquals(Set<byte[]> set1, Set<byte[]> set2, boolean expectEquals) {
    set1.add(new byte[] {1, 2, 3});
    set1.add(new byte[] {4, 5, 6});
    set2.add(new byte[] {1, 2, 3});
    set2.add(new byte[] {4, 5, 6});

    if (expectEquals) {
      assertEquals(set1, set2);
      assertEquals(set1.hashCode(), set2.hashCode());
    } else
      assertFalse(
          String.format(
              "Expected set1=%s to be distinct to set2=%s", set1.toString(), set2.toString()),
          set1.equals(set2));
  }
Пример #19
0
 @Override
 public int hashCode() {
   int result = packageNames.hashCode();
   result = 31 * result + parameters.hashCode();
   result = 31 * result + resolution.hashCode();
   return result;
 }
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((departments == null) ? 0 : departments.hashCode());
   return result;
 }
Пример #21
0
  private void calcHashCode() {

    this.hashCode = 13;

    hashCode += types.hashCode();
    hashCode += properties.hashCode() * 31;
  }
 @Override
 public int hashCode() {
   int result = consumes.hashCode();
   result = 31 * result + produces.hashCode();
   result = 31 * result + name.hashCode();
   return result;
 }
 @Override
 public int hashCode() {
   int result = type != null ? type.hashCode() : 0;
   result = 31 * result + (interval != null ? interval.hashCode() : 0);
   result = 31 * result + (functions != null ? functions.hashCode() : 0);
   return result;
 }
Пример #24
0
  @Override
  public int hashCode() {
    int hash = 17;
    hash = hash * 31 + patterns.hashCode();

    return hash;
  }
Пример #25
0
  public void update() {

    tick++;
    if (tick == 2) {
      internal =
          new LinkedHashSet<Class>(
              ((MyClassLoader) Trampoline2.trampoline.getClassLoader()).getAllLoadedClasses());
      ; // ;//System.out.println(" ----------- reload plugin ----------");
      populateTree();
    } else if (tick > 2) {

      Control c = Launcher.display.getFocusControl();
      if (c == null) return;
      Shell s = c.getShell();
      if (s.getText().trim().length() == 0) return;

      Set<Class> allClass =
          ((MyClassLoader) Trampoline2.trampoline.getClassLoader()).getAllLoadedClasses();
      int hashNow = allClass.hashCode();
      if (hashNow != hashWas && willRep < 0) {
        willRep = 5;
      }
    }

    willRep--;
    if (willRep == 0) {
      populateTree();
    }
  }
Пример #26
0
 @Override
 public int hashCode() {
   final int prime = 347;
   int result = super.hashCode();
   result = prime * result + bvsNames.hashCode();
   return result;
 }
 @Override
 public int hashCode() {
   int result = environment != null ? environment.hashCode() : 0;
   result = 31 * result + (honeybadgerUrl != null ? honeybadgerUrl.hashCode() : 0);
   result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0);
   result = 31 * result + (excludedSysProps != null ? excludedSysProps.hashCode() : 0);
   result = 31 * result + (excludedParams != null ? excludedParams.hashCode() : 0);
   result = 31 * result + (excludedClasses != null ? excludedClasses.hashCode() : 0);
   result = 31 * result + (applicationPackage != null ? applicationPackage.hashCode() : 0);
   result = 31 * result + (honeybadgerReadApiKey != null ? honeybadgerReadApiKey.hashCode() : 0);
   result = 31 * result + (feedbackFormDisplayed != null ? feedbackFormDisplayed.hashCode() : 0);
   result = 31 * result + (feedbackFormPath != null ? feedbackFormPath.hashCode() : 0);
   result = 31 * result + (httpProxyHost != null ? httpProxyHost.hashCode() : 0);
   result = 31 * result + (httpProxyPort != null ? httpProxyPort.hashCode() : 0);
   return result;
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((set == null) ? 0 : set.hashCode());
   return result;
 }
Пример #29
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((group == null) ? 0 : group.hashCode());
   result = prime * result + (junction ? 1231 : 1237);
   return result;
 }
Пример #30
0
 @Override
 public int hashCode() {
   int result = handler.hashCode();
   result = 31 * result + attributeAppenderFactory.hashCode();
   result = 31 * result + methodDescription.hashCode();
   result = 31 * result + typeTokens.hashCode();
   return result;
 }