Challenge...

20 views
Skip to first unread message

Niclas Hedhman

unread,
Oct 6, 2014, 5:03:32 AM10/6/14
to qi4j...@googlegroups.com

Just a tiny observation... Stream API in Java 8 is the equivalent of our "Iterables" system that Rickard built up, on similar principles.

An example from the web

public class Student { public String getName() { return name } }
List<string> names = students.stream().map(Student::getName).filter(name->name.startsWith("A"))


Now, what we JUST HAVE TO support in Qi4j is;

public interface Student { Property<String> name(); }
List<string> names = students.stream().map(Student::name).filter(name->name.startsWith("A"))

"Somehow" the name().get() must be automatically called under the hood in the map() method. Just have to!!! 

Put on the THINKING HATS about this.


Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

Stanislav Muhametsin

unread,
Oct 6, 2014, 5:03:37 PM10/6/14
to qi4j...@googlegroups.com
Hi everyone,

It's been a long time, but the Qi4CS (the Qi4j port for CLR environment)
is finally here. It is not yet as 'perfect' as I'd like it to be (e.g.
Mono support is not fully there, as I need Ubuntu virtual machine to
perform Mono builds, and Mono's xbuild is quite incomplete compared to
msbuild), but it's getting there.

Some key points:
- The repository is available at https://github.com/CometaSolutions/Qi4CS
- The license is Apache v2 and there is NOTICE file about the origins
of Qi4CS, along with attributions on file basis, where applicable
(please let me know if something is amiss/wrong)
- This isn't exactly "port" in most strict sense - CLR type system is
so different from Java that I had to take my own path right after
defining the basic things in API (e.g. SPI, Runtime, etc are *very*
different from their Java counterparts)
- Therefore, if you are coming from Qi4j world, most stuff in API
namespace should be familiar (albeit maybe located in 'odd' place)
- Currently no proper documentation (API docs are there, but what I
mean is actual, proper documentation explaining things) - this is mainly
initial push from private repository (the stuff exists tho, it just
needs some fixing up)
- No version control history from before making this public - the
import is from private repository

The repository README file lists next things to do, that is, publishing
NuGet package (something like Maven package in CLR world), and then
publishing some documentation as well. I hope I'll get around to do at
least the NuGet package upload and quick sample during this week. The
sample should work even with free version of MSVS so everyone will be
able to test Qi4CS out. :)

If any questions arised, feel free to ask them.

Paul Merlin

unread,
Oct 14, 2014, 6:30:15 AM10/14/14
to qi4j...@googlegroups.com
Niclas,

Niclas Hedhman a écrit :
Just a tiny observation... Stream API in Java 8 is the equivalent of our "Iterables" system that Rickard built up, on similar principles.

An example from the web

public class Student { public String getName() { return name } }
List<string> names = students.stream().map(Student::getName).filter(name->name.startsWith("A"))


Now, what we JUST HAVE TO support in Qi4j is;

public interface Student { Property<String> name(); }
List<string> names = students.stream().map(Student::name).filter(name->name.startsWith("A"))

"Somehow" the name().get() must be automatically called under the hood in the map() method. Just have to!!! 

Put on the THINKING HATS about this.
I tried several ways, here are the code samples:
https://gist.github.com/eskatos/f46bae317fbce5617063

It does not depend on Qi4j, simply demonstrating that it compiles.
Thus, some interfaces are not implemented.

To sum up, I don't think this is possible without some additional syntaxic sugar :/

In addition to what already work out of the box, two approaches are shown in the gist:

1. using a custom Collector
2. using a custom Stream class + a static factory method for it
 

Neither 1. nor 2. achieve what you whished.

My 2 cents

/Paul

Paul Merlin

unread,
Oct 14, 2014, 6:30:37 AM10/14/14
to qi4j...@googlegroups.com
Hi Stan,

Interesting, ambitious.

Keep us informed :)

Cheers

/Paul

Reply all
Reply to author
Forward
0 new messages