Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dwh-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AKTIN
dwh-api
Commits
f14e76be
Commit
f14e76be
authored
Jul 12, 2016
by
R.W.M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new preferences API with configuration injection
parent
b1211885
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
0 deletions
+84
-0
src/main/java/org/aktin/Configurable.java
src/main/java/org/aktin/Configurable.java
+27
-0
src/main/java/org/aktin/ConfigurationTest.java
src/main/java/org/aktin/ConfigurationTest.java
+5
-0
src/main/java/org/aktin/Module.java
src/main/java/org/aktin/Module.java
+9
-0
src/main/java/org/aktin/Preference.java
src/main/java/org/aktin/Preference.java
+20
-0
src/main/java/org/aktin/Preferences.java
src/main/java/org/aktin/Preferences.java
+11
-0
src/main/java/org/aktin/prefs/Validator.java
src/main/java/org/aktin/prefs/Validator.java
+12
-0
No files found.
src/main/java/org/aktin/Configurable.java
0 → 100644
View file @
f14e76be
package
org.aktin
;
import
java.lang.reflect.Method
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* Marker interface to allow automatic injection of configuration preferences
*
* @author R.W.Majeed
*
*/
public
interface
Configurable
{
public
default
List
<
String
>
getPreferences
(){
List
<
String
>
prefs
=
new
LinkedList
<>();
Method
[]
methods
=
getClass
().
getDeclaredMethods
();
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++
){
Preference
pref
=
methods
[
i
].
getAnnotation
(
Preference
.
class
);
if
(
pref
!=
null
){
prefs
.
add
(
pref
.
id
());
}
}
return
prefs
;
}
}
src/main/java/org/aktin/ConfigurationTest.java
0 → 100644
View file @
f14e76be
package
org.aktin
;
public
interface
ConfigurationTest
{
}
src/main/java/org/aktin/Module.java
0 → 100644
View file @
f14e76be
package
org.aktin
;
public
abstract
class
Module
implements
Configurable
{
public
String
getVersion
(){
return
getClass
().
getPackage
().
getImplementationVersion
();
}
}
src/main/java/org/aktin/Preference.java
0 → 100644
View file @
f14e76be
package
org.aktin
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
/**
* AKTIN preference. If the annotation is used, also implement the {@link Configurable} interface.
*
* TODO add annotation processor to verify at compile time that each preference id is unique and method types are void(SingleArg)
*
* @author R.W.Majeed
*
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Preference
{
String
id
();
String
example
()
default
""
;
}
src/main/java/org/aktin/Preferences.java
0 → 100644
View file @
f14e76be
package
org.aktin
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Preferences
{
String
group
();
// TODO add Class<?> validator() to validate preferences
}
\ No newline at end of file
src/main/java/org/aktin/prefs/Validator.java
0 → 100644
View file @
f14e76be
package
org.aktin.prefs
;
/**
* Validates preference settings.
* A validator may work for one or more preferences,
* e.g for R executable (one preference) or email server settings (multiple)
* @author R.W.Majeed
*
*/
public
interface
Validator
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment