@Test public void hashCodeTestWithNullField () { Container container = new EqualityTestContainer(null, 42); assertEquals(42, container.hashCode()); }
@Override public int hashCode () { List<Field> identifyingFields = getIdentifyingFields(); AtomicInteger result = new AtomicInteger(0); identifyingFields.stream() .map(field -> { try { return field.get(this); } catch (IllegalAccessException e) { log.error("Caught IllegalAccessException while evaluating hashcode", e); return null; } }) .mapToInt(o -> Optional.ofNullable(o).map(Object::hashCode).orElse(0)) .forEachOrdered(i -> result.set(result.get() * 31 + i)); return result.get(); }
Container implements ExperimentalObject { @Override public int hashCode () { List<Field> identifyingFields = getIdentifyingFields(); AtomicInteger result = new AtomicInteger(0); identifyingFields.stream() .map(field -> { try { return field.get(this); } catch (IllegalAccessException e) { log.error("Caught IllegalAccessException while evaluating hashcode", e); return null; } }) .mapToInt(o -> Optional.ofNullable(o).map(Object::hashCode).orElse(0)) .forEachOrdered(i -> result.set(result.get() * 31 + i)); return result.get(); } }
Container implements ExperimentalObject { @Override public int hashCode () { List<Field> identifyingFields = getIdentifyingFields(); AtomicInteger result = new AtomicInteger(0); identifyingFields.stream() .map(field -> { try { return field.get(this); } catch (IllegalAccessException e) { log.error("Caught IllegalAccessException while evaluating hashcode", e); return null; } }) .mapToInt(o -> Optional.ofNullable(o).map(Object::hashCode).orElse(0)) .forEachOrdered(i -> result.set(result.get() * 31 + i)); return result.get(); }  }
Container implements ExperimentalObject { @Override public int hashCode () { List<Field> identifyingFields = getIdentifyingFields(); AtomicInteger result = new AtomicInteger(0); identifyingFields.stream() .map(field -> { try { return field.get(this); } catch (IllegalAccessException e) { log.error("Caught IllegalAccessException while evaluating hashcode", e); return null; } }) .mapToInt(o -> Optional.ofNullable(o).map(Object::hashCode).orElse(0)) .forEachOrdered(i -> result.set(result.get() * 31 + i)); return result.get(); }  Map<String, Boolean> getShellCapabilities(); @JsonIgnore Map<String, String> getDataDogTags(); @Override boolean canExperiment(); @JsonIgnore abstract Platform getPlatform(); boolean eligibleForExperiments(); Experiment createExperiment(); @Override boolean equals(Object o); @Override int hashCode(); long getIdentity(); @Override String toString(); ContainerHealth getContainerHealth(ExperimentType experimentType); Experiment createExperiment(String experimentMethod); void startExperiment(Experiment experiment); abstract String getSimpleName(); abstract String getAggregationIdentifier(); String getContainerType(); @JsonIgnore Duration getMinimumSelfHealingInterval(); @JsonIgnore abstract DataDogIdentifier getDataDogIdentifier(); boolean compareUniqueIdentifier(String uniqueIdentifier); void setMappedDiagnosticContext(); void clearMappedDiagnosticContext(); @JsonIgnore List<Method> getExperimentMethods(); @SuppressWarnings("unchecked") Runnable recycleCattle(); boolean isCattle(); boolean supportsShellBasedExperiments(); @SuppressWarnings("unchecked") ShellOutput runCommand(String command); @JsonIgnore Boolean isContainerRecycled(); @SuppressWarnings("unchecked") String runScript(Script script); Instant getExperimentStartTime(); Collection<String> getKnownMissingCapabilities(); void clearExperiment(); boolean supportsExperimentScope(ExperimentScope experimentScope); }
Container implements ExperimentalObject { @Override public int hashCode () { List<Field> identifyingFields = getIdentifyingFields(); AtomicInteger result = new AtomicInteger(0); identifyingFields.stream() .map(field -> { try { return field.get(this); } catch (IllegalAccessException e) { log.error("Caught IllegalAccessException while evaluating hashcode", e); return null; } }) .mapToInt(o -> Optional.ofNullable(o).map(Object::hashCode).orElse(0)) .forEachOrdered(i -> result.set(result.get() * 31 + i)); return result.get(); }  Map<String, Boolean> getShellCapabilities(); @JsonIgnore Map<String, String> getDataDogTags(); @Override boolean canExperiment(); @JsonIgnore abstract Platform getPlatform(); boolean eligibleForExperiments(); Experiment createExperiment(); @Override boolean equals(Object o); @Override int hashCode(); long getIdentity(); @Override String toString(); ContainerHealth getContainerHealth(ExperimentType experimentType); Experiment createExperiment(String experimentMethod); void startExperiment(Experiment experiment); abstract String getSimpleName(); abstract String getAggregationIdentifier(); String getContainerType(); @JsonIgnore Duration getMinimumSelfHealingInterval(); @JsonIgnore abstract DataDogIdentifier getDataDogIdentifier(); boolean compareUniqueIdentifier(String uniqueIdentifier); void setMappedDiagnosticContext(); void clearMappedDiagnosticContext(); @JsonIgnore List<Method> getExperimentMethods(); @SuppressWarnings("unchecked") Runnable recycleCattle(); boolean isCattle(); boolean supportsShellBasedExperiments(); @SuppressWarnings("unchecked") ShellOutput runCommand(String command); @JsonIgnore Boolean isContainerRecycled(); @SuppressWarnings("unchecked") String runScript(Script script); Instant getExperimentStartTime(); Collection<String> getKnownMissingCapabilities(); void clearExperiment(); boolean supportsExperimentScope(ExperimentScope experimentScope);  }