Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelConverter classes should expose Java collections objects rather than scala #438

Closed
rage-shadowman opened this issue Jan 20, 2014 · 5 comments
Labels
Milestone

Comments

@rage-shadowman
Copy link

ModelConverter classes all expect and return scala immutable collections objects. This makes it very difficult to work with them in Java. If they would expose Java collections objects, it would be much easier.

Methods: ignoredClasses, ignoredPackages, typeMap, skippedClasses

@davidecavestro
Copy link

In the meantime how can I redefine i.e. ignoredPackages using only Java or Groovy? I 've found no way to populate a scala.collection.immutable.Set<String> from those languages.

UPDATE: the following hack works

...
        @Override
        public Set<String> ignoredPackages() {
            scala.collection.mutable.LinkedHashSet set = new scala.collection.mutable.LinkedHashSet()
            def pkgs = [
                'java.lang',
                'groovy.lang',
                'java.util'
            ] as LinkedHashSet
            pkgs << delegateConverter.ignoredPackages()
            pkgs.each {set.add (it)}
            set.toSet()
        }
...

@rage-shadowman
Copy link
Author

There is a hideous set of tools in the scala.collection.JavaConverters class. They can be used, but they are a major PITA to work with. If you look on stackoverflow, there are a lot of examples of how to turn java collection classes into scala equivalents. The scala.collection.JavaConversions class is much nicer to work with but unfortunately it only generates mutable objects.

@rage-shadowman
Copy link
Author

Here is an example for java.util.Set to scala.collection.immutable.Set that isn't too much of a PITA:

java.util.Set<String> javaUtilOverrides = new HashSet<String>(
    Arrays.asList( new String[] {
      "java.lang",
      "groovy.lang",
      "java.util"
   } ) );
scala.collection.immutable.Set<String> scalaIgnoredPackageOverrides = JavaConverters
    .asScalaSetConverter( javaUtilOverrides )
    .asScala()
    .toSet();

@davidecavestro
Copy link

Cool. Many thanks!

Inviato da Samsung Mobile

Shadow Man notifications@github.com ha scritto:

Here is an example for java.util.Set to scala.collection.immutable.Set that isn't too much of a PITA:

java.util.Set javaUtilOverrides = new HashSet(
Arrays.asList( new String[] {
"java.lang",
"groovy.lang",
"java.util"
} ) );
scala.collection.immutable.Set scalaIgnoredPackageOverrides = JavaConverters
.asScalaSetConverter( javaUtilOverrides )
.asScala()
.toSet();

Reply to this email directly or view it on GitHub.

@fehguy fehguy modified the milestone: v1.5.0 Sep 19, 2014
@fehguy fehguy modified the milestones: v1.5.0-M1, v1.5.0 Dec 20, 2014
@fehguy
Copy link
Contributor

fehguy commented Dec 23, 2014

moved to #588

@fehguy fehguy closed this as completed Dec 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants