Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Axiom: Added special handling for AxiomTypeReference
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
- Loading branch information
1 parent
4de9cd2
commit 4c0f8bd
Showing
18 changed files
with
580 additions
and
267 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
58 changes: 58 additions & 0 deletions
58
infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/AxiomSchemaContextImpl.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,58 @@ | ||
package com.evolveum.axiom.lang.impl; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import com.evolveum.axiom.api.AxiomIdentifier; | ||
import com.evolveum.axiom.lang.api.AxiomBuiltIn; | ||
import com.evolveum.axiom.lang.api.AxiomItemDefinition; | ||
import com.evolveum.axiom.lang.api.AxiomSchemaContext; | ||
import com.evolveum.axiom.lang.api.AxiomTypeDefinition; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
public class AxiomSchemaContextImpl implements AxiomSchemaContext { | ||
|
||
private Map<AxiomIdentifier, AxiomItemDefinition> roots; | ||
private Map<AxiomIdentifier, AxiomTypeDefinition> types; | ||
|
||
public AxiomSchemaContextImpl(Map<AxiomIdentifier, AxiomItemDefinition> roots, | ||
Map<AxiomIdentifier, AxiomTypeDefinition> types) { | ||
this.roots = roots; | ||
this.types = types; | ||
} | ||
|
||
public static AxiomSchemaContext of(Map<AxiomIdentifier, AxiomItemDefinition> roots, | ||
Map<AxiomIdentifier, AxiomTypeDefinition> types) { | ||
return new AxiomSchemaContextImpl(roots, types); | ||
} | ||
|
||
@Override | ||
public Collection<AxiomItemDefinition> roots() { | ||
return roots.values(); | ||
} | ||
|
||
@Override | ||
public Optional<AxiomTypeDefinition> getType(AxiomIdentifier type) { | ||
return Optional.ofNullable(types.get(type)); | ||
} | ||
|
||
@Override | ||
public Collection<AxiomTypeDefinition> types() { | ||
return types.values(); | ||
} | ||
|
||
@Override | ||
public Optional<AxiomItemDefinition> getRoot(AxiomIdentifier type) { | ||
return Optional.ofNullable(roots.get(type)); | ||
} | ||
|
||
public static AxiomSchemaContextImpl boostrapContext() { | ||
return new AxiomSchemaContextImpl(ImmutableMap.of(AxiomBuiltIn.Item.MODEL_DEFINITION.name(), AxiomBuiltIn.Item.MODEL_DEFINITION), | ||
ImmutableMap.of()); | ||
} | ||
|
||
public static AxiomSchemaContext baseLanguageContext() { | ||
return ModelReactorContext.BASE_LANGUAGE.get(); | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/Deffered.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,40 @@ | ||
package com.evolveum.axiom.lang.impl; | ||
|
||
import java.util.Optional; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
class Deffered<T> extends Requirement.Delegated<T> { | ||
|
||
private Object ret; | ||
|
||
Deffered(Requirement<T> delegate) { | ||
ret = delegate; | ||
} | ||
|
||
@Override | ||
Requirement<T> delegate() { | ||
if(ret instanceof Requirement<?>) { | ||
return (Requirement<T>) ret; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isSatisfied() { | ||
if(delegate() != null) { | ||
if(delegate().isSatisfied()) { | ||
ret = delegate().get(); | ||
} else { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public T get() { | ||
Preconditions.checkState(isSatisfied(), "Requirement was not satisfied"); | ||
return (T) ret; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/DelegatedRequirement.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,7 @@ | ||
package com.evolveum.axiom.lang.impl; | ||
|
||
import java.util.Optional; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
|
Oops, something went wrong.