Skip to content

Commit

Permalink
@Matches and @NotMatches annotations used by Refaster-based recip…
Browse files Browse the repository at this point in the history
…es (#3488)

* `@Matches` and `@NotMatches` annotations used by Refaster-based recipes

* Add `@Incubating`
  • Loading branch information
knutwannheden authored Aug 22, 2023
1 parent b78f4d5 commit 44d49af
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2023 the original author or authors.
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.openrewrite.java.template;

import org.openrewrite.Incubating;
import org.openrewrite.java.tree.J;

@Incubating(since = "8.3.0")
@FunctionalInterface
public interface Matcher<T extends J> {
boolean matches(T t);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2023 the original author or authors.
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.openrewrite.java.template;

import org.openrewrite.Incubating;
import org.openrewrite.java.tree.Expression;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Incubating(since = "8.3.0")
@Target(ElementType.PARAMETER)
public @interface Matches {
Class<? extends Matcher<? super Expression>> value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2023 the original author or authors.
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.openrewrite.java.template;

import org.openrewrite.Incubating;
import org.openrewrite.java.tree.Expression;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Incubating(since = "8.3.0")
@Target(ElementType.PARAMETER)
public @interface NotMatches {
Class<? extends Matcher<? super Expression>> value();
}

0 comments on commit 44d49af

Please sign in to comment.