remove if's for stream filter I've the following code which check for duplicate property and provide and warning when the key is exist and provide error if the key and the value have the same values. 
The code have done some iteration and its working
my question is there is a way to avoid the if's statement's  ? 

      Map&lt;String, Object&gt; existProp = requires.get(reqidx).getProperties();
        Optional&lt;Map.Entry&lt;String, Object&gt;&gt; foundProperty = properties.entrySet().stream().filter(property -&gt; existProp.containsKey(property.getKey())).findFirst();
        if (foundProperty.isPresent()) {
            // Same key already exists 
            LOG.warn("Property with key {} already exists in requires {}", foundProperty.get().getKey(), requires.get(reqidx).getName());
            // in case the existing property has the same value (check only for value of type String)
            if (foundProperty.get().getValue() instanceof String
                    &amp;&amp; existProp.get(foundProperty.get().getKey()) instanceof String
                    &amp;&amp; (foundProperty.get().getValue()).equals(existProp.get(foundProperty.get().getKey()))) {
                throw new Exception("Property " + foundProperty.get().getKey() + "  exists already with value " + foundProperty.get().getValue() + " in requires " + requiresName);
            }
        }
        return reqidx;
    }
Every Optional.isPresent() can be replaced with the fluent Optional.ifPresent() which takes a Consumer function arg (that can be lambda expr) which accepts the value of the Optional.get()

properties.entrySet().stream().filter(property -&gt; existProp.containsKey(property.getKey()))
.findFirst().ifPresent(foundPropertyValue -&gt; {
  // Same key already exists 
  LOG.warn("Property with key {} already exists in requires {}", foundPropertyValue.getKey(), requires.get(reqidx).getName());
  // in case the existing property has the same value (check only for value of type String)
  if (foundPropertyValue.getValue() instanceof String
      &amp;&amp; existProp.get(foundPropertyValue.getKey()) instanceof String
      &amp;&amp; (foundPropertyValue.getValue()).equals(existProp.get(foundPropertyValue.getKey()))) {
        throw new Exception("Property " + foundPropertyValue.getKey() + "  exists already with value " + foundPropertyValue.getValue() + " in requires " + requiresName);
  }
});