Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
3334d7dc
Commit
3334d7dc
authored
10 years ago
by
Simon Barner
Browse files
Options
Downloads
Patches
Plain Diff
- Use getSpecification() also internally and avoid loops in every wrapped method
- Add private getAnnotationValueProvider() method refs 1841
parent
58221030
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationEntry.java
+85
-80
85 additions, 80 deletions
...g/fortiss/tooling/base/ui/annotation/AnnotationEntry.java
with
85 additions
and
80 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/AnnotationEntry.java
+
85
−
80
View file @
3334d7dc
...
...
@@ -79,10 +79,10 @@ public final class AnnotationEntry {
/** Returns the name / "label" for a given annotation {@code clazz}. */
public
String
getSpecificationAnnotationName
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
for
(
IAnnotatedSpecification
s
:
s
pecification
sList
)
{
if
(
clazz
.
isInstance
(
s
))
{
return
providerSpecMapping
.
get
(
clazz
).
getAnnotationName
(
s
);
}
IAnnotatedSpecification
s
pecification
=
getS
pecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
getAnnotationName
(
specification
);
}
return
null
;
...
...
@@ -93,11 +93,11 @@ public final class AnnotationEntry {
*/
public
void
setSpecificationAnnotationName
(
String
name
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
providerSpecMapping
.
get
(
clazz
).
setAnnotationName
(
name
,
s
);
return
;
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
getAnnotationValueProvider
(
clazz
).
setAnnotationName
(
name
,
specification
);
}
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
...
...
@@ -105,14 +105,11 @@ public final class AnnotationEntry {
/** Predicate if the given annotation can be edited. */
public
boolean
canEdit
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
try
{
return
providerSpecMapping
.
get
(
clazz
).
canEdit
(
s
);
}
catch
(
Exception
e
)
{
return
false
;
}
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
canEdit
(
specification
);
}
return
false
;
...
...
@@ -120,14 +117,10 @@ public final class AnnotationEntry {
/** Predicate if the given annotation can be edited. */
public
boolean
canEdit
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
,
String
instanceKey
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
try
{
return
providerSpecMapping
.
get
(
clazz
).
canEdit
(
s
,
instanceKey
);
}
catch
(
Exception
e
)
{
return
false
;
}
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
canEdit
(
specification
,
instanceKey
);
}
return
false
;
...
...
@@ -136,13 +129,15 @@ public final class AnnotationEntry {
/** Returns the annotation value */
public
<
V
>
V
getSpecificationValue
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
,
String
instanceKey
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
try
{
return
providerSpecMapping
.
get
(
clazz
).
getAnnotationValue
(
s
,
instanceKey
);
}
catch
(
Exception
e
)
{
return
null
;
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
try
{
return
getAnnotationValueProvider
(
clazz
).
getAnnotationValue
(
specification
,
instanceKey
);
}
catch
(
Exception
e
)
{
// Ignore exception
}
}
...
...
@@ -154,13 +149,14 @@ public final class AnnotationEntry {
* support.
*/
public
<
V
>
V
getSpecificationValue
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
try
{
return
providerSpecMapping
.
get
(
clazz
).
getAnnotationValue
(
s
);
}
catch
(
Exception
e
)
{
// Ignore exception
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
try
{
return
getAnnotationValueProvider
(
clazz
).
getAnnotationValue
(
specification
);
}
catch
(
Exception
e
)
{
// Ignore exception
}
}
...
...
@@ -172,14 +168,14 @@ public final class AnnotationEntry {
*/
public
<
V
>
void
setSpecificationValue
(
V
value
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
,
String
instanceKey
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
providerSpecMapping
.
get
(
clazz
).
setAnnotationValue
(
value
,
s
,
instanceKey
);
return
;
}
}
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
getAnnotationValueProvider
(
clazz
).
setAnnotationValue
(
value
,
specification
,
instanceKey
);
}
else
{
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
}
}
/**
...
...
@@ -187,14 +183,14 @@ public final class AnnotationEntry {
*/
public
void
setSpecificationValue
(
String
value
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
,
String
instanceKey
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
providerSpecMapping
.
get
(
clazz
).
setAnnotationValue
(
value
,
s
,
instanceKey
);
return
;
}
}
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
getAnnotationValueProvider
(
clazz
).
setAnnotationValue
(
value
,
specification
,
instanceKey
);
}
else
{
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
}
}
/**
...
...
@@ -202,14 +198,13 @@ public final class AnnotationEntry {
*/
public
<
V
>
void
setSpecificationValue
(
V
value
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
providerSpecMapping
.
get
(
clazz
).
setAnnotationValue
(
value
,
s
);
return
;
}
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
if
(
specification
!=
null
)
{
getAnnotationValueProvider
(
clazz
).
setAnnotationValue
(
value
,
specification
);
}
else
{
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
}
}
/**
...
...
@@ -217,14 +212,14 @@ public final class AnnotationEntry {
*/
public
void
setSpecificationValue
(
String
value
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
providerSpecMapping
.
get
(
clazz
).
setAnnotationValue
(
value
,
s
);
return
;
}
}
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
getAnnotationValueProvider
(
clazz
).
setAnnotationValue
(
value
,
specification
);
}
else
{
throw
new
Exception
(
"Could not find a AnnotationValueProvider for "
+
clazz
.
toString
());
}
}
/**
...
...
@@ -236,11 +231,12 @@ public final class AnnotationEntry {
*/
public
EditingSupport
createSpecificationEditElement
(
ColumnViewer
viewer
,
Class
<?
extends
IAnnotatedSpecification
>
clazz
,
String
instanceKey
)
throws
Exception
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
return
providerSpecMapping
.
get
(
clazz
).
createEditingSupport
(
viewer
,
clazz
,
s
,
instanceKey
);
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
createEditingSupport
(
viewer
,
clazz
,
specification
,
instanceKey
);
}
return
null
;
...
...
@@ -254,10 +250,11 @@ public final class AnnotationEntry {
* latter case, this method returns current list of dynamic annotation instances.
*/
public
Collection
<
String
>
getInstanceKeys
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
return
providerSpecMapping
.
get
(
clazz
).
getInstanceKeys
(
s
);
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
getInstanceKeys
(
specification
);
}
return
Collections
.
emptyList
();
...
...
@@ -271,10 +268,11 @@ public final class AnnotationEntry {
* {@link List} of admissible instance keys.
*/
public
boolean
allowsDynamicAnnotationInstances
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
for
(
IAnnotatedSpecification
s
:
specificationsList
)
{
if
(
clazz
.
isInstance
(
s
))
{
return
providerSpecMapping
.
get
(
clazz
).
allowsDynamicAnnotationInstances
();
}
IAnnotatedSpecification
specification
=
getSpecification
(
clazz
);
if
(
specification
!=
null
)
{
return
getAnnotationValueProvider
(
clazz
).
allowsDynamicAnnotationInstances
();
}
return
false
;
...
...
@@ -290,6 +288,13 @@ public final class AnnotationEntry {
return
specificationsList
;
}
/** Determine the value provider for the given annotation class. */
private
IAnnotationValueProvider
<
IAnnotatedSpecification
>
getAnnotationValueProvider
(
Class
<?
extends
IAnnotatedSpecification
>
clazz
)
{
return
providerSpecMapping
.
get
(
clazz
);
}
/**
* Returns the {@link IAnnotatedSpecification} of a given {@code clazz} managed by this
* {@link AnnotationEntry}.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment