forked from objectionary/jeo-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(objectionary#534): use DirectivesAnnotationDefault to read annot…
…ations default values
- Loading branch information
1 parent
c376d11
commit 5c78823
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/eolang/jeo/representation/directives/DirectivesAnnotationDefault.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 @@ | ||
package org.eolang.jeo.representation.directives; | ||
|
||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import org.xembly.Directive; | ||
import org.xembly.Directives; | ||
|
||
public final class DirectivesAnnotationDefault implements Iterable<Directive>, Composite { | ||
|
||
private final AtomicReference<Iterable<Directive>> value; | ||
|
||
public DirectivesAnnotationDefault() { | ||
this(new AtomicReference<>()); | ||
} | ||
|
||
public DirectivesAnnotationDefault(final AtomicReference<Iterable<Directive>> value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Iterator<Directive> iterator() { | ||
if (this.value.get() != null) { | ||
final Directives directives = new Directives() | ||
.add("o") | ||
.attr("name", "annotation-default-value"); | ||
directives.append(this.value.get()); | ||
return directives.up().iterator(); | ||
} else { | ||
return Collections.emptyIterator(); | ||
} | ||
} | ||
|
||
@Override | ||
public void append(final Iterable<Directive> directives) { | ||
this.value.set(directives); | ||
} | ||
|
||
@Override | ||
public Iterable<Directive> build() { | ||
return this; | ||
} | ||
} |
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