Coder Social home page Coder Social logo

Comments (3)

mishkaowner avatar mishkaowner commented on September 26, 2024

I reckon, I need to check if this problem Is related with Retrolambda instead.

from lightweight-stream-api.

aNNiMON avatar aNNiMON commented on September 26, 2024

@mishkaowner thanks for feedback.

I've tried to reproduce the issue with this code
import com.annimon.stream.Stream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class Issue88 {
    
    public static void main(String[] args) {
        final List<AnswerType> ansTypes = Arrays.asList(AnswerType.values());

        Stream<ChatQuestion> stream1 = Stream.range(0, 4)
                        .flatMap(i -> Stream.of(new ChatQuestion()));
        Stream<ChatAnswer> stream2 = Stream.zip(
                Stream.range(0, 4)
                        .flatMap(i -> Stream.of(new ChatAnswer())),
                Stream.of(ansTypes),
                (value1, value2) -> {
                    value1.setAnswerType(value2);
                    return value1;
                });

        final List<ChatQuestion> chatQuestions = new ArrayList<>();
        Stream.zip(stream1, stream2, (value1, value2) -> {
            value1.getAnswers().add(value2);
            return value1;
        }).forEach(chatQuestion -> chatQuestions.add(chatQuestion));

        Stream.of(chatQuestions).forEach(System.out::println);
    }

    private static class ChatQuestion {

        private final List<ChatAnswer> answers;

        public ChatQuestion() {
            this.answers = new ArrayList<>();
        }

        public List<ChatAnswer> getAnswers() {
            return answers;
        }

        @Override
        public String toString() {
            return "ChatQuestion: " + answers.toString();
        }
    }

    private static class ChatAnswer {

        private AnswerType answerType;

        public void setAnswerType(AnswerType type) {
            this.answerType = type;
        }

        @Override
        public String toString() {
            return "ChatAnswer{" + "answerType=" + answerType + '}';
        }
    }

    private enum AnswerType { TYPE1, TYPE2, TYPE3, TYPE4 };
}

but it works fine and returns:

ChatQuestion: [ChatAnswer{answerType=TYPE1}]
ChatQuestion: [ChatAnswer{answerType=TYPE2}]
ChatQuestion: [ChatAnswer{answerType=TYPE3}]
ChatQuestion: [ChatAnswer{answerType=TYPE4}]

Tried on 1.1.2 and 1.1.4 versions.

from lightweight-stream-api.

javadev avatar javadev commented on September 26, 2024

Issue may be closed, I think

from lightweight-stream-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.