Skip to content

Commit babd9da

Browse files
Egima profilepivovarit
authored andcommitted
Javaslang project (eugenp#927)
* made changes to java reflection * removed redundant method makeSound in Animal abstract class * added project for play-framework article * added project for regex * changed regex project from own model to core-java * added project for routing in play * made changes to regex project * refactored code for REST API with Play project * refactored student store indexing to zero base * added unit tests, removed bad names * added NIO Selector project under core-java module * requested changes made * added project for nio2 * standardized exception based tests * fixed exception based tests * removed redundant files * added network interface project * used UUID other than timestamps * fixed network interface tests * removed filetest change * made changes to NIO2 FileTest names * added project for asyncronous channel apis * added project for NIO2 advanced filesystems APIS * merge conflicts * merged changes to asyncfiletest with future get API * removed while loops from async client and server * added project for java8 optional * fixed merge conflicts in spring-core * fixed optional * fixed optional * fixed asyncechotest * shifted optional to own package * made additional tests to demo filter API * added code for Map * added javaslang project * javaslang project * added pattern matcher code
1 parent c5b67b5 commit babd9da

6 files changed

Lines changed: 554 additions & 0 deletions

File tree

‎javaslang/pom.xml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>Javaslang</artifactId>
6+
<version>1.0</version>
7+
<name>Javaslang</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<groupId>org.apache.maven.plugins</groupId>
12+
<artifactId>maven-compiler-plugin</artifactId>
13+
<version>3.3</version>
14+
<configuration>
15+
<source>1.8</source>
16+
<target>1.8</target>
17+
</configuration>
18+
</plugin>
19+
</plugins>
20+
</build>
21+
<dependencies>
22+
<dependency>
23+
<groupId>junit</groupId>
24+
<artifactId>junit</artifactId>
25+
<version>4.12</version>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.hamcrest</groupId>
30+
<artifactId>hamcrest-all</artifactId>
31+
<version>1.3</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>io.javaslang</groupId>
35+
<artifactId>javaslang</artifactId>
36+
<version>2.1.0-alpha</version>
37+
</dependency>
38+
39+
40+
</dependencies>
41+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.javaslang;
2+
3+
public class Person {
4+
private String name;
5+
private int age;
6+
7+
public Person(String name, int age) {
8+
super();
9+
this.name = name;
10+
this.age = age;
11+
}
12+
13+
public Person() {
14+
super();
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public int getAge() {
26+
return age;
27+
}
28+
29+
public void setAge(int age) {
30+
this.age = age;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return "Person [name=" + name + ", age=" + age + "]";
36+
}
37+
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.javaslang;
2+
3+
import javaslang.collection.List;
4+
import javaslang.control.Validation;
5+
6+
class PersonValidator {
7+
String NAME_ERR = "Invalid characters in name: ";
8+
String AGE_ERR = "Age must be at least 0";
9+
10+
public Validation<List<String>, Person> validatePerson(String name, int age) {
11+
return Validation.combine(validateName(name), validateAge(age)).ap(Person::new);
12+
}
13+
14+
private Validation<String, String> validateName(String name) {
15+
String invalidChars = name.replaceAll("[a-zA-Z ]", "");
16+
return invalidChars.isEmpty() ? Validation.valid(name) : Validation.invalid(NAME_ERR + invalidChars);
17+
}
18+
19+
private Validation<String, Integer> validateAge(int age) {
20+
return age < 0 ? Validation.invalid(AGE_ERR) : Validation.valid(age);
21+
}
22+
}

0 commit comments

Comments
 (0)