-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from lukaszbudnik/scala-support
Scala support
- Loading branch information
Showing
9 changed files
with
216 additions
and
52 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
.idea/ | ||
build/ | ||
target/ | ||
.gradle/ | ||
.DS_Store | ||
jelvis.iml | ||
gugis.iml | ||
gradle/ | ||
gradlew | ||
gradlew.bat | ||
|
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
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
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
22 changes: 22 additions & 0 deletions
22
src/main/scala/com/github/lukaszbudnik/jelvis/ElvisScalaToJavaConverters.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (C) 2015 Łukasz Budnik <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.github.lukaszbudnik.jelvis | ||
|
||
import java.util.function.{Function => JFunction} | ||
|
||
object ElvisScalaToJavaConverters { | ||
|
||
implicit def toJavaFunction[A, B](f: Function1[A, B]) = new JFunction[A, B] { | ||
override def apply(a: A): B = f(a) | ||
|
||
def fromScala: Boolean = true | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (C) 2015 Łukasz Budnik <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.github.lukaszbudnik.jelvis; | ||
|
||
final class Model { | ||
|
||
static class Country { | ||
String getISOCode() { | ||
return "PL"; | ||
} | ||
} | ||
|
||
static class Address { | ||
Country getCountry() { | ||
return null; | ||
} | ||
|
||
String getGeoLocation() throws Exception { | ||
throw new RuntimeException("Geo location declares Exception but is throwing runtime exception"); | ||
} | ||
|
||
// throws unchecked exception | ||
String getLine1() { | ||
throw new RuntimeException("getLine1 threw runtime exception"); | ||
} | ||
|
||
// throws checked exception | ||
String getLine2() throws Exception { | ||
throw new Exception("getLine2 threw checked exception"); | ||
} | ||
} | ||
|
||
static class Person { | ||
Address getAddress() { | ||
return new Address(); | ||
} | ||
|
||
int getIQ() throws Exception { | ||
return 100; | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2015 Łukasz Budnik <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
--> | ||
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %c{1.} - %msg%n"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Logger name="com.github.lukaszbudnik.jelvis" level="debug" additivity="false"> | ||
<AppenderRef ref="Console"/> | ||
</Logger> | ||
<Root level="info"> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
Oops, something went wrong.