Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Merge pull request #105 from metafacture/14-addJavaIntegration
Browse files Browse the repository at this point in the history
Add Java integration.
  • Loading branch information
blackwinter authored Jan 26, 2022
2 parents 1159022 + 79ef8e6 commit fd3f28d
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 126 deletions.
8 changes: 4 additions & 4 deletions metafix/src/main/java/org/metafacture/metafix/Fix.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ Expression:
;

Unless:
'unless' name = ValidID '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
'unless' name = QualifiedName '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
elements += Expression*
'end'
;

If:
'if' name = ValidID '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
'if' name = QualifiedName '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
elements += Expression*
elseIf = ElsIf?
else = Else?
'end'
;

ElsIf:
'elsif' name = ValidID '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
'elsif' name = QualifiedName '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* )? ')'
elements += Expression*
;

Expand All @@ -46,7 +46,7 @@ Do:
;

MethodCall:
name = ValidID '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* ','? )? ( options = Options )? ')'
name = QualifiedName '(' ( params += (QualifiedName|STRING) ( ',' params += (QualifiedName|STRING) )* ','? )? ( options = Options )? ')'
;

Options:
Expand Down
90 changes: 90 additions & 0 deletions metafix/src/main/java/org/metafacture/metafix/FixConditional.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2021 Fabian Steeg, hbz
*
* 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 org.metafacture.metafix;

import org.metafacture.metafix.api.FixPredicate;

import java.util.List;
import java.util.Map;

public enum FixConditional implements FixPredicate {

all_contain {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ALL, CONTAINS);
}
},
any_contain {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ANY, CONTAINS);
}
},
none_contain {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return !any_contain.test(metafix, record, params, options);
}
},

all_equal {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ALL, EQUALS);
}
},
any_equal {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ANY, EQUALS);
}
},
none_equal {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return !any_equal.test(metafix, record, params, options);
}
},

exists {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return record.containsField(params.get(0));
}
},

all_match {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ALL, MATCHES);
}
},
any_match {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return testConditional(record, params, ANY, MATCHES);
}
},
none_match {
@Override
public boolean test(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
return !any_match.test(metafix, record, params, options);
}
}

}
Loading

0 comments on commit fd3f28d

Please sign in to comment.