Skip to content

Commit

Permalink
⚙️ :: (#2) Publication 옵션 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
smoothbear committed May 27, 2021
1 parent f1d3490 commit 239e03b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ plugins {
id 'maven-publish'
}

sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
}

group 'io.github.team-xquare'
version '0.0.8'
version '0.0.9'

repositories {
mavenCentral()
Expand All @@ -19,7 +30,6 @@ repositories {
dependencies {
testRuntimeOnly 'org.codehaus.groovy:groovy'
testImplementation "org.spockframework:spock-core:$spockVersion"
testImplementation "org.spockframework:spock-spring:$spockVersion"
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.0'
}

Expand All @@ -44,11 +54,9 @@ artifacts {
publishing {
publications {
maven(MavenPublication) {
groupId = 'io.github.team-xquare'
artifactId = 'utils'
version = '0.0.8'

from components.java
artifact("build/libs/lib-$version" + ".jar") {
extension 'jar'
}
}
}
repositories {
Expand Down
50 changes: 50 additions & 0 deletions lib/src/main/java/validator/StudentValidator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package validator;

import java.util.Arrays;
import java.util.regex.Pattern;

/**
Expand All @@ -16,4 +17,53 @@ public static boolean isEmailValid(String email) {

return pattern.matcher(email).matches();
}

/**
* @param gcn 학번
* @param type 학년
* @return true: 검증 성공, false: 검증 실패
*/
public static boolean isGradeValid(Integer gcn, Integer type) {
int grade = gcn / 1000;

return type.equals(grade);
}

/**
* 학번으로 해당 학년이 맞는지 검사합니다.
* @param gcn 학번
* @param types 학년(복수 매개변수 가능)
* @return true: 검증 성공, false: 검증 실패
*/
public static boolean isGradeValid(Integer gcn, Integer... types) {
int grade = gcn / 1000;

return Arrays.asList(types).contains(grade);
}

/**
* 학번으로 해당 학년이 맞는지 검사합니다.
* @param gcn 학번
* @param type 학년
* @return true: 검증 성공, false: 검증 실패
*/
public static boolean isGradeValid(String gcn, Integer type) {
Pattern pattern = Pattern.compile("^[" + type + "]");

return pattern.matcher(gcn).matches();
}

/**
* 학번으로 해당 학년이 맞는지 검사합니다.
* @param gcn 학번
* @param types 학년(복수 매개변수 가능)
* @return true: 검증 성공, false: 검증 실패
*/
public static boolean isGradeValid(String gcn, Integer... types) {
return Arrays.stream(types).anyMatch(type -> {
Pattern pattern = Pattern.compile("^[" + type + "]");

return pattern.matcher(gcn).matches();
});
}
}

0 comments on commit 239e03b

Please sign in to comment.