Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Axiom: Renamed reactor context to reflect Item & Value terminology
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
- Loading branch information
1 parent
d919536
commit aae76b6
Showing
9 changed files
with
85 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ default AxiomItemValue<V> onlyValue() { | |
return Iterables.getOnlyElement(values()); | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomItemFactory.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,9 @@ | ||
package com.evolveum.axiom.lang.api; | ||
|
||
import java.util.Collection; | ||
|
||
public interface AxiomItemFactory<V> { | ||
|
||
AxiomItem<V> create(AxiomItemDefinition def, Collection<? extends AxiomItemValue<?>> axiomItem); | ||
|
||
} |
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
51 changes: 51 additions & 0 deletions
51
infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomItemValueBuilder.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,51 @@ | ||
package com.evolveum.axiom.lang.api; | ||
|
||
import com.evolveum.axiom.concepts.Lazy; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
import java.util.function.Supplier; | ||
|
||
import javax.annotation.concurrent.NotThreadSafe; | ||
|
||
import com.evolveum.axiom.api.AxiomIdentifier; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableMap.Builder; | ||
|
||
@NotThreadSafe | ||
public class AxiomItemValueBuilder<V,T extends AxiomItemValue<V>> implements Lazy.Supplier<T> { | ||
|
||
private final AxiomTypeDefinition type; | ||
|
||
private final AxiomItemValueFactory<V,T> factory; | ||
private Map<AxiomIdentifier, Supplier<? extends AxiomItem<?>>> children = new LinkedHashMap<>(); | ||
private V value; | ||
|
||
public AxiomItemValueBuilder(AxiomTypeDefinition type, AxiomItemValueFactory<V,T> factory) { | ||
this.type = type; | ||
this.factory = factory; | ||
} | ||
|
||
public V getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(V value) { | ||
this.value = value; | ||
} | ||
|
||
public void add(AxiomIdentifier name, Supplier<? extends AxiomItem<?>> child) { | ||
children.put(name, child); | ||
} | ||
|
||
@Override | ||
public T get() { | ||
Builder<AxiomIdentifier, AxiomItem<?>> builder = ImmutableMap.builder(); | ||
for(Entry<AxiomIdentifier, Supplier<? extends AxiomItem<?>>> entry : children.entrySet()) { | ||
builder.put(entry.getKey(), entry.getValue().get()); | ||
} | ||
return factory.create(type, value, builder.build().values()); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomItemValueFactory.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,9 @@ | ||
package com.evolveum.axiom.lang.api; | ||
|
||
import java.util.Collection; | ||
|
||
public interface AxiomItemValueFactory<V,T extends AxiomItemValue<V>> { | ||
|
||
T create(AxiomTypeDefinition def, V value, Collection<AxiomItem<?>> items); | ||
} | ||
|
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
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