-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add customizeValidOnly option (#1103)
- Loading branch information
Showing
16 changed files
with
379 additions
and
29 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...api/src/main/java/com/navercorp/fixturemonkey/api/matcher/DefaultTreeMatcherMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* 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.navercorp.fixturemonkey.api.matcher; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Set; | ||
|
||
import org.apiguardian.api.API; | ||
import org.apiguardian.api.API.Status; | ||
|
||
@API(since = "1.0.4", status = Status.EXPERIMENTAL) | ||
public final class DefaultTreeMatcherMetadata implements TreeMatcherMetadata { | ||
private final Set<Annotation> annotations; | ||
|
||
public DefaultTreeMatcherMetadata(Set<Annotation> annotations) { | ||
this.annotations = annotations; | ||
} | ||
|
||
@Override | ||
public Set<Annotation> getAnnotations() { | ||
return annotations; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/matcher/TreeMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* 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.navercorp.fixturemonkey.api.matcher; | ||
|
||
import org.apiguardian.api.API; | ||
import org.apiguardian.api.API.Status; | ||
|
||
/** | ||
* It is mainly used to customize the ObjectTree that meets the specific condition with {@link TreeMatcherOperator}. | ||
* <p> | ||
* The main difference to the {@link Matcher} is the scope. | ||
* {@link Matcher} is intended to reference the nodes of the ObjectTree, | ||
* but {@link TreeMatcher} is intended to reference the ObjectTree itself. | ||
* | ||
* @see Matcher | ||
*/ | ||
@API(since = "1.0.4", status = Status.EXPERIMENTAL) | ||
@FunctionalInterface | ||
public interface TreeMatcher { | ||
/** | ||
* Determines if the ObjectTree meets the condition. | ||
* | ||
* @param metadata the metadata of the ObjectTree | ||
* @return {@code true} if the condition matches, {@code false} if not matches | ||
*/ | ||
boolean match(TreeMatcherMetadata metadata); | ||
} |
38 changes: 38 additions & 0 deletions
38
...monkey-api/src/main/java/com/navercorp/fixturemonkey/api/matcher/TreeMatcherMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* 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.navercorp.fixturemonkey.api.matcher; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Set; | ||
|
||
import org.apiguardian.api.API; | ||
import org.apiguardian.api.API.Status; | ||
|
||
/** | ||
* It contains the metadata of the ObjectTree. | ||
*/ | ||
@API(since = "1.0.4", status = Status.EXPERIMENTAL) | ||
public interface TreeMatcherMetadata { | ||
/** | ||
* Retrieves the annotations of all nodes in the ObjectTree. | ||
* | ||
* @return the annotations of all nodes | ||
*/ | ||
Set<Annotation> getAnnotations(); | ||
} |
42 changes: 42 additions & 0 deletions
42
...monkey-api/src/main/java/com/navercorp/fixturemonkey/api/matcher/TreeMatcherOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* 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.navercorp.fixturemonkey.api.matcher; | ||
|
||
import org.apiguardian.api.API; | ||
import org.apiguardian.api.API.Status; | ||
|
||
@API(since = "1.0.4", status = Status.EXPERIMENTAL) | ||
public final class TreeMatcherOperator<T> implements TreeMatcher { | ||
private final TreeMatcher matcher; | ||
private final T operator; | ||
|
||
public TreeMatcherOperator(TreeMatcher matcher, T operator) { | ||
this.matcher = matcher; | ||
this.operator = operator; | ||
} | ||
|
||
@Override | ||
public boolean match(TreeMatcherMetadata metadata) { | ||
return this.matcher.match(metadata); | ||
} | ||
|
||
public T getOperator() { | ||
return operator; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...y-api/src/main/java/com/navercorp/fixturemonkey/api/option/BuilderContextInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* 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.navercorp.fixturemonkey.api.option; | ||
|
||
import org.apiguardian.api.API; | ||
import org.apiguardian.api.API.Status; | ||
|
||
/** | ||
* It is a public API to customize the ObjectTree. | ||
* <p> | ||
* It should contain the customizing options for the ObjectTree, not for the node. | ||
*/ | ||
@API(since = "1.1.4", status = Status.EXPERIMENTAL) | ||
public final class BuilderContextInitializer { | ||
private final boolean validOnly; | ||
|
||
private BuilderContextInitializer(boolean validOnly) { | ||
this.validOnly = validOnly; | ||
} | ||
|
||
public static BuilderContextInitializer validOnly(boolean validOnly) { | ||
return new BuilderContextInitializer(validOnly); | ||
} | ||
|
||
public boolean isValidOnly() { | ||
return validOnly; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.