Skip to content

Commit

Permalink
Merge pull request #612 from opatrascoiu/master-refactor
Browse files Browse the repository at this point in the history
Master refactor
  • Loading branch information
opatrascoiu authored Jan 4, 2024
2 parents 69c44ea + 730ddc2 commit 3ae214c
Show file tree
Hide file tree
Showing 325 changed files with 5,327 additions and 3,831 deletions.

This file was deleted.

75 changes: 75 additions & 0 deletions dmn-core/src/main/java/com/gs/dmn/ast/ReferenceVisitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2016 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.gs.dmn.ast;

import com.gs.dmn.DRGElementReference;
import com.gs.dmn.runtime.DMNRuntimeException;

public interface ReferenceVisitor<C, R> {
// References
default R visit(DRGElementReference<? extends TDRGElement> reference, C context) {
TDRGElement element = reference.getElement();
R result;
if (element == null) {
result = null;
} else if (element instanceof TInputData) {
result = visitInputReference((DRGElementReference<TInputData>) reference, context);
} else if (element instanceof TDecision) {
result = visitDecisionReference((DRGElementReference<TDecision>) reference, context);
} else if (element instanceof TBusinessKnowledgeModel) {
result = visitBKMReference((DRGElementReference<TBusinessKnowledgeModel>) reference, context);
} else if (element instanceof TDecisionService) {
result = visitDSReference((DRGElementReference<TDecisionService>) reference, context);
} else if (element instanceof TKnowledgeSource) {
result = visitSourceReference((DRGElementReference<TKnowledgeSource>) reference, context);
} else {
throw new DMNRuntimeException(String.format("Not supported for class '%s'", element.getClass().getSimpleName()));
}
return result;
}

default R visitInvocable(DRGElementReference<? extends TInvocable> reference, C context) {
TInvocable element = reference.getElement();
R result;
if (element == null) {
throw new DMNRuntimeException(String.format("Cannot visit invocable '%s'", reference));
} else if (element instanceof TBusinessKnowledgeModel) {
result = visitBKMReference((DRGElementReference<TBusinessKnowledgeModel>) reference, context);
} else if (element instanceof TDecisionService) {
result = visitDSReference((DRGElementReference<TDecisionService>) reference, context);
} else {
throw new DMNRuntimeException(String.format("Not supported type '%s'", element.getClass().getSimpleName()));
}
return result;
}

default R visitInputReference(DRGElementReference<TInputData> reference, C context) {
return null;
}

default R visitDecisionReference(DRGElementReference<TDecision> reference, C context) {
return null;
}

default R visitBKMReference(DRGElementReference<TBusinessKnowledgeModel> reference, C context) {
return null;
}

default R visitDSReference(DRGElementReference<TDecisionService> reference, C context) {
return null;
}

default R visitSourceReference(DRGElementReference<TKnowledgeSource> reference, C context) {
return null;
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TAssociation.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setAssociationDirection(TAssociationDirection value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void setRequiredAuthority(TDMNElementReference value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setExpression(TExpression value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setURI(String value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public List<TAuthorityRequirement> getAuthorityRequirement() {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setExpression(TExpression expression) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TConditional.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setElse(TChildExpression elseExp) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<TContextEntry> getContextEntry() {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TContextEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void setExpression(TExpression value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setHref(String value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TDecision.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void setExpression(TExpression value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TDecisionRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<TRuleAnnotation> getAnnotationEntry() {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<TDMNElementReference> getInputData() {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TDecisionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void setOutputLabel(String value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
2 changes: 1 addition & 1 deletion dmn-core/src/main/java/com/gs/dmn/ast/TDefinitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void setExporterVersion(String value) {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public List<TDMNElementReference> getDrgElement() {
}

@Override
public <C> Object accept(Visitor visitor, C context) {
public <C, R> R accept(Visitor<C, R> visitor, C context) {
return visitor.visit(this, context);
}
}
Loading

0 comments on commit 3ae214c

Please sign in to comment.