Skip to main content
0 votes
2 answers
107 views

Interface overriding extending functional interface method as default and having an abstract method works abruptly

@FunctionalInterface interface StringConsumer extends Consumer<String> { @Override public default void accept(String s) { System.out.println(s.toUpperCase()); } void ...
Alper ARSLAN's user avatar
-3 votes
1 answer
186 views

Mocked method inside lambda expression is not working

I am using the mockito but connection.prepareStatement is not getting matched and I am getting null as PreparedStatement. I have checked connection is getting mocked properly void myMethod(){ ...
Ankur Singh's user avatar
0 votes
1 answer
281 views

Instance of object without implementing an interface [duplicate]

I have a code sample that defines a Worker interface and an Employee class that does not implement that interface. In my main method, I declare a Worker called w and instantiate it as an Employee. ...
mah454's user avatar
  • 1,948
0 votes
2 answers
198 views

Can not create Function array in Java 8

I have a class called SFunction which extends from Function in JDK 8 @FunctionalInterface public interface SFunction<T, R> extends Function<T, R>, Serializable { } Now I have several ...
flyingfox's user avatar
  • 13.5k
0 votes
1 answer
198 views

Struggling to inject my mocked Runnable into my service call

For context, I'm using Resilience4j to handle exceptions and invoke retries. This is done through RetryService. In this function, callRunnableWithRetry() there are two params. 1st is a string, the 2nd ...
frlzjosh's user avatar
  • 464
0 votes
1 answer
89 views

Java FunctionalInterface with variable number of arguments

I want to write a very lightweight library method, that will take any number of java lambda functions, execute them with auto-commit turned off. Should an error occur it would rollback. So the lambda ...
dogTurd's user avatar
  • 188
0 votes
2 answers
1k views

Predicates and functions

public static void main(String[] args) { List<String> strings = Arrays.asList("a", "b", "c", "d"); strings.stream() .filter(s -> ...
l a s's user avatar
  • 3,923
0 votes
1 answer
51 views

@FunctionalProtocols for Swift?

My Problem I'm looking for a while for an equivalent of Javas @FunctionalInterface in Swift. Swift is titled as Protocol-Oriented Programming Language and known for his Syntactic Sugar. So I hope ...
code_by_cr's user avatar
0 votes
0 answers
50 views

BiFunction error during method reference with multiple arguments

I'm working on a code to put objects to S3. I've a wrapper method that logs the call details and request/ response information. While i try to use the wrapper for s3.putObject/ s3.headObject calls, ...
AsteriK's user avatar
  • 39
1 vote
2 answers
94 views

Unable to pass Consumer<> instance

I have a class for walking a directory tree and performing an action on each file/directory. It looks like this: class DirWalker { public static void walkDirs(Path startingPath, Consumer<Path>...
melston's user avatar
  • 2,374
1 vote
3 answers
156 views

Java BiFunction to manipulate data over an iteration

I'm writing a Java code that looks like this, and I have the feel it could be improved with some functional programming stuff :) int rank = 1; for (int i = 0; i < activities.size(); i++) { if (...
Alain Carmona's user avatar
-1 votes
1 answer
72 views

Storing methods in fields in java (cleanly)

My situation is designing my game with Javas OOP as clean as I can I need to store static methods of the another class into a field of current without using try{}catch{}. Being more specific I need to ...
varikoz272's user avatar
1 vote
0 answers
34 views

Method compose, in interface Function

public Function<V, U> compose(Function<? super V, ? extends T> before) Can someone explain the way "? super T" works, why we need "super" in this interface to make ...
GUST4's user avatar
  • 11
-1 votes
1 answer
73 views

using functional interfaces in java [closed]

I have ProductSettings and ProductType. Product settings determine whether product types are enabled or not. ProductSettings productSettings = new ProductSettings() ....
Aleksandr Berestov's user avatar
-1 votes
1 answer
110 views

How to make a static version of a Map holding getters/setters of an object?

I have a map I build when called on object that provides caller with variable names as key and getter/setter pair as values. This works as expected. My issue is that I build it every time I call for ...
Smrt's user avatar
  • 31

15 30 50 per page
1
2 3 4 5
40