-
Notifications
You must be signed in to change notification settings - Fork 0
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 #6 from ingokuba/validations
Add validations to property and replace regex and required.
- Loading branch information
Showing
16 changed files
with
570 additions
and
67 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
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,20 @@ | ||
# This workflow will build a Java project with Maven | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
vulnerability: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
- name: Vulnerability check | ||
run: mvn org.owasp:dependency-check-maven:5.3.2:check -DfailBuildOnAnyVulnerability=true -DsuppressionFiles=suppression.xml |
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
66 changes: 66 additions & 0 deletions
66
src/main/java/de/intension/halo/AnnotationTransformer.java
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,66 @@ | ||
package de.intension.halo; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Map; | ||
|
||
import de.intension.halo.entity.Property; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Transforms a property based on the given annotation. | ||
* <br/> | ||
* <br/> | ||
* Implement this class with a simple constructor that calls sets the annotation type. | ||
* | ||
* <pre> | ||
* public class ExampleTransformer | ||
* extends AnnotationTransformer<ExampleAnnotation> | ||
* { | ||
* public ExampleTransformer() | ||
* { | ||
* super(ExampleAnnotation.class); | ||
* } | ||
* ... | ||
* } | ||
* </pre> | ||
*/ | ||
@RequiredArgsConstructor | ||
public abstract class AnnotationTransformer<T extends Annotation> | ||
{ | ||
|
||
@NonNull | ||
private Class<T> annotationType; | ||
|
||
/** | ||
* Check whether annotation class matches <b><T></b>. | ||
* | ||
* @param type Class of the annotation that is checked. | ||
* @return <b>true</b> if annotation matches. | ||
*/ | ||
public final boolean matchesAnnotation(Class<? extends Annotation> type) | ||
{ | ||
return annotationType.equals(type); | ||
} | ||
|
||
/** | ||
* Transform the property based on the information of an annotation. | ||
* | ||
* @param annotation Annotation to take information from. | ||
* @param property Property to transform. | ||
*/ | ||
public abstract void transformProperty(T annotation, Property property); | ||
|
||
/** | ||
* Transform the property based on the information of an annotation and use localization. | ||
* Override this method if localization is needed for the transformation. | ||
* | ||
* @param annotation Annotation to take information from. | ||
* @param property Property to transform. | ||
* @param locales Localization provider. | ||
*/ | ||
public void transformProperty(T annotation, Property property, Map<String, Map<String, String>> locales) | ||
{ | ||
transformProperty(annotation, property); | ||
} | ||
} |
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,35 @@ | ||
package de.intension.halo.entity; | ||
|
||
import java.util.Map; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Accessors; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
@NoArgsConstructor | ||
@RequiredArgsConstructor | ||
public class Validation | ||
{ | ||
|
||
/** | ||
* | ||
*/ | ||
@NonNull | ||
private String name; | ||
/** | ||
* Validation object. | ||
*/ | ||
@NonNull | ||
private Object value; | ||
/** | ||
* Multi-language message of the validation. | ||
* | ||
* @param message Set mappings of language code to translation. | ||
* @return Mappings of language code to translation. | ||
*/ | ||
private Map<String, String> message; | ||
} |
Oops, something went wrong.