This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.functional.programming.model; | |
public class Person { | |
private String name; | |
public String getName() { | |
return name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.functional.programming.intf; | |
import com.example.functional.programming.model.Person; | |
@FunctionalInterface | |
public interface PersonFunctionalInterface { | |
Person createPerson(String name); | |
default String getDefaultMethodString() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public SimpleStream<T> map(Function<T, T> function) { | |
List<T> returnValueList = new ArrayList<>(); | |
for (T value : values) { | |
returnValueList.add(value + " String"); | |
} | |
this.values = returnValueList; | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void initializeOptional_optionalOf() { | |
Optional<String> helloWorldOptional = Optional.of("Hello, world"); | |
assert helloWorldOptional.isPresent(); | |
assert "Hello, world".equals(helloWorldOptional.get()); | |
} |