Skip to content

Commit 6f66c57

Browse files
committed
Added getCore() as default to interfaces instance and attribute to simplify core access
1 parent d33d923 commit 6f66c57

File tree

7 files changed

+23
-10
lines changed

7 files changed

+23
-10
lines changed

src/main/java/de/s42/dl/DLAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public interface DLAnnotation extends DLEntity
6262
}
6363

6464
public DLAnnotated getContainer();
65-
65+
6666
public boolean hasParameters();
6767

6868
public Object[] getFlatParameters();

src/main/java/de/s42/dl/DLAttribute.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public interface DLAttribute extends DLEntity, DLAnnotated, DLValidatable
5656

5757
public DLType getContainer();
5858

59+
default public DLCore getCore()
60+
{
61+
return getContainer().getCore();
62+
}
63+
5964
public Object getDefaultValue();
6065

6166
public DLType getType();
@@ -66,19 +71,22 @@ public interface DLAttribute extends DLEntity, DLAnnotated, DLValidatable
6671
public List<DLAttributeValidator> getValidators();
6772

6873
public boolean validateValue(Object value, ValidationResult result);
69-
74+
7075
// FLAGS
7176
public boolean isReadable();
7277

7378
public boolean isWritable();
7479

7580
/**
76-
* This method shall return true if the data represented by this attribute is equal (same type, same annnotations, ... but not same container)
81+
* This method shall return true if the data represented by this attribute is equal (same type, same annnotations,
82+
* ... but not same container)
83+
*
7784
* @param other
78-
* @return
85+
*
86+
* @return
7987
*/
8088
public boolean equalDataType(DLAttribute other);
81-
89+
8290
public boolean equalOrMoreSpecificDataType(DLAttribute other);
83-
91+
8492
}

src/main/java/de/s42/dl/DLInstance.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ default public boolean isUnnamed()
5252
}
5353

5454
public DLType getType();
55+
56+
default public DLCore getCore()
57+
{
58+
return getType().getCore();
59+
}
5560

5661
// VALIDATION
5762
public boolean addValidator(DLInstanceValidator validator);

src/main/java/de/s42/dl/annotations/instances/ExportDLAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public void bindToInstance(DLInstance instance) throws InvalidInstance
4646
container = instance;
4747
container.addAnnotation(this);
4848

49-
instance.getType().getCore().addExported(instance);
49+
instance.getCore().addExported(instance);
5050
}
5151
}

src/main/java/de/s42/dl/parser/DLHrfParsing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static Object[] fetchStaticParameters(DLModule module, String annotationN
128128
return new Object[0];
129129
}
130130

131-
DLCore core = module.getType().getCore();
131+
DLCore core = module.getCore();
132132

133133
DLAnnotationFactory annotationFactory = core.getAnnotationFactory(annotationName).orElseThrow(() -> {
134134
return new InvalidAnnotation(createErrorMessage(module, "Annotation factory @" + annotationName + " is not defined", ctx));

src/main/java/de/s42/dl/parser/contracts/DLHrfContractParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private static ContractExpression buildContract(DLModule module, AnnotationConte
135135
try {
136136
String annotationName = ctx.annotationName().getText();
137137

138-
DLCore core = module.getType().getCore();
138+
DLCore core = module.getCore();
139139

140140
if (!core.hasAnnotationFactory(annotationName)) {
141141
throw new DLHrfParsingException(

src/main/java/de/s42/dl/parser/expression/DLHrfExpressionParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static Object resolveReference(DLModule module, String refId, ParserRuleC
244244
assert refId != null;
245245
assert ctx != null;
246246

247-
DLCore core = module.getType().getCore();
247+
DLCore core = module.getCore();
248248

249249
assert core != null;
250250

0 commit comments

Comments
 (0)