Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Raphael
histream
Commits
3fb959bc
Commit
3fb959bc
authored
Nov 16, 2016
by
R.W.Majeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extension return instance types with appropriate generic type
parent
df61035a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
65 deletions
+10
-65
histream-core/src/main/java/de/sekmi/histream/Extension.java
histream-core/src/main/java/de/sekmi/histream/Extension.java
+1
-1
histream-core/src/main/java/de/sekmi/histream/impl/ClassExtension.java
.../src/main/java/de/sekmi/histream/impl/ClassExtension.java
+0
-60
histream-core/src/main/java/de/sekmi/histream/impl/SimplePatientExtension.java
...n/java/de/sekmi/histream/impl/SimplePatientExtension.java
+4
-2
histream-core/src/main/java/de/sekmi/histream/impl/SimpleVisitExtension.java
...ain/java/de/sekmi/histream/impl/SimpleVisitExtension.java
+5
-2
No files found.
histream-core/src/main/java/de/sekmi/histream/Extension.java
View file @
3fb959bc
...
...
@@ -58,6 +58,6 @@ public interface Extension<T>{
* TODO change return type to array, to register all compatible classes
* @return instance type
*/
Class
<?>[]
getInstanceTypes
();
Iterable
<
Class
<?
super
T
>>
getInstanceTypes
();
}
histream-core/src/main/java/de/sekmi/histream/impl/ClassExtension.java
deleted
100644 → 0
View file @
df61035a
package
de.sekmi.histream.impl
;
import
de.sekmi.histream.Extension
;
import
de.sekmi.histream.Observation
;
import
de.sekmi.histream.ext.IdExtensionType
;
/**
* Extension to allow grouping/classification of facts.
* This can be seen similar to the {@code class} attribute
* in HTML which can be given to any element.
* <p>
* XXX still need to figure how to serialize the class id
* to the {@code fact/@class} attribute.
* </p>
*
* @author R.W.Majeed
*
*/
public
class
ClassExtension
implements
Extension
<
ClassExtension
.
Clazz
>
{
public
static
class
Clazz
implements
IdExtensionType
{
private
String
id
;
@Override
public
String
getId
()
{
return
id
;
}
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
@Override
public
Clazz
createInstance
(
Observation
observation
)
{
// TODO use modifier "class" to get the class value
// otherwise unable to create a class for the given observation
throw
new
UnsupportedOperationException
();
//return null;
}
@Override
public
Clazz
createInstance
(
Object
...
args
)
throws
UnsupportedOperationException
,
IllegalArgumentException
{
if
(
args
.
length
!=
1
||
!(
args
[
0
]
instanceof
String
)
){
throw
new
IllegalArgumentException
(
"Fact extension for class needs exactly one string argument for the class id"
);
}
Clazz
c
=
new
Clazz
();
c
.
setId
((
String
)
args
[
0
]);
return
c
;
}
@Override
public
Class
<?>[]
getInstanceTypes
()
{
return
new
Class
[]{
Clazz
.
class
};
}
}
histream-core/src/main/java/de/sekmi/histream/impl/SimplePatientExtension.java
View file @
3fb959bc
package
de.sekmi.histream.impl
;
import
java.util.Arrays
;
/*
* #%L
* histream
...
...
@@ -34,10 +36,10 @@ import de.sekmi.histream.ext.Patient;
*
*/
public
class
SimplePatientExtension
implements
Extension
<
PatientImpl
>{
private
final
static
Class
<?>[]
TYPES
=
new
Class
<?>[]{
Patient
.
class
,
PatientImpl
.
class
}
;
private
final
static
Iterable
<
Class
<?
super
PatientImpl
>>
TYPES
=
Arrays
.
asList
(
Patient
.
class
,
PatientImpl
.
class
)
;
@Override
public
Class
<?>[]
getInstanceTypes
()
{
return
TYPES
;}
public
Iterable
<
Class
<?
super
PatientImpl
>>
getInstanceTypes
()
{
return
TYPES
;}
@Override
public
PatientImpl
createInstance
(
Object
...
args
)
{
...
...
histream-core/src/main/java/de/sekmi/histream/impl/SimpleVisitExtension.java
View file @
3fb959bc
...
...
@@ -22,16 +22,19 @@ package de.sekmi.histream.impl;
import
de.sekmi.histream.Observation
;
import
java.util.Arrays
;
import
de.sekmi.histream.Extension
;
import
de.sekmi.histream.ext.ExternalSourceType
;
import
de.sekmi.histream.ext.Patient
;
import
de.sekmi.histream.ext.Visit
;
public
class
SimpleVisitExtension
implements
Extension
<
VisitImpl
>{
private
final
static
Class
<?>[]
TYPES
=
new
Class
<?>[]{
Visit
.
class
,
VisitImpl
.
class
}
;
private
final
static
Iterable
<
Class
<?
super
VisitImpl
>>
TYPES
=
Arrays
.
asList
(
Visit
.
class
,
VisitImpl
.
class
)
;
@Override
public
Class
<?>[]
getInstanceTypes
()
{
return
TYPES
;}
public
Iterable
<
Class
<?
super
VisitImpl
>>
getInstanceTypes
()
{
return
TYPES
;}
@Override
public
VisitImpl
createInstance
(
Object
...
args
)
{
...
...
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