Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/axiom' into feature/metadata-mappings
- Loading branch information
Showing
77 changed files
with
6,946 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Copyright (c) 2010-2018 Evolveum and contributors | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>infra</artifactId> | ||
<groupId>com.evolveum.midpoint.infra</groupId> | ||
<version>4.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>com.evolveum.axiom</groupId> | ||
<artifactId>axiom</artifactId> | ||
|
||
<name>Axiom</name> | ||
|
||
<properties> | ||
<maven.test.skip>true</maven.test.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-runtime</artifactId> | ||
<version>4.8-1</version> | ||
</dependency> | ||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.evolveum.midpoint.tools</groupId> | ||
<artifactId>test-ng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-maven-plugin</artifactId> | ||
<version>4.8-1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>antlr4</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<visitor>true</visitor> | ||
<listener>true</listener> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
45 changes: 45 additions & 0 deletions
45
infra/axiom/src/main/antlr4/com/evolveum/axiom/lang/antlr/Axiom.g4
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,45 @@ | ||
grammar Axiom; | ||
|
||
SEMICOLON : ';'; | ||
LEFT_BRACE : '{'; | ||
RIGHT_BRACE : '}'; | ||
COLON : ':'; | ||
PLUS : '+'; | ||
LINE_COMMENT : [ \n\r\t]* ('//' (~[\r\n]*)) [ \n\r\t]* -> skip; | ||
SEP: [ \n\r\t]+; | ||
IDENTIFIER : [a-zA-Z_/][a-zA-Z0-9_\-./]*; | ||
|
||
fragment SQOUTE : '\''; | ||
fragment DQOUTE : '"'; | ||
|
||
|
||
//fragment SUB_STRING : ('"' (ESC | ~["])*? '"') | ('\'' (ESC | ~['])* '\''); | ||
//fragment ESC : '\\' (["\\/bfnrt] | UNICODE); | ||
//fragment UNICODE : 'u' HEX HEX HEX HEX; | ||
//fragment HEX : [0-9a-fA-F] ; | ||
//STRING: ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | '}' | '/' | '+')~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '}' )* ) | SUB_STRING ); | ||
|
||
fragment ESC : '\\'; | ||
|
||
STRING_SINGLEQUOTE: SQOUTE ((ESC SQOUTE) | ~[\n'])* SQOUTE; | ||
STRING_DOUBLEQUOTE: DQOUTE ((ESC DQOUTE) | ~[\n"])* DQOUTE; | ||
//STRING_MULTILINE: '"""' (ESC | ~('"""'))* '"""'; | ||
statement : SEP* identifier SEP* (argument)? SEP* (SEMICOLON | LEFT_BRACE SEP* (statement)* SEP* RIGHT_BRACE SEP*) SEP*; | ||
identifier : (prefix COLON)? localIdentifier; | ||
prefix : IDENTIFIER; | ||
localIdentifier : IDENTIFIER; | ||
// argument : STRING (SEP* PLUS SEP* STRING)* | IDENTIFIER; | ||
argument : identifier | string; | ||
string : singleQuoteString | doubleQuoteString | multilineString; | ||
singleQuoteString : STRING_SINGLEQUOTE; | ||
doubleQuoteString : STRING_DOUBLEQUOTE; | ||
multilineString: '"""\n' (~('"""'))*'"""'; | ||
74 changes: 74 additions & 0 deletions
74
infra/axiom/src/main/java/com/evolveum/axiom/api/AxiomIdentifier.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,74 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.axiom.api; | ||
|
||
import java.util.Objects; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
public class AxiomIdentifier { | ||
|
||
public static final String AXIOM_NAMESPACE = "https://ns.evolveum.com/axiom"; | ||
private final String namespace; | ||
private final String localName; | ||
|
||
public AxiomIdentifier(String namespace, String localName) { | ||
this.namespace = Preconditions.checkNotNull(namespace, "namespace"); | ||
this.localName = Preconditions.checkNotNull(localName, "localName"); | ||
} | ||
|
||
public String getNamespace() { | ||
return namespace; | ||
} | ||
|
||
public String getLocalName() { | ||
return localName; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((localName == null) ? 0 : localName.hashCode()); | ||
result = prime * result + ((namespace == null) ? 0 : namespace.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (!(obj instanceof AxiomIdentifier)) | ||
return false; | ||
AxiomIdentifier other = (AxiomIdentifier) obj; | ||
if (localName == null) { | ||
if (other.localName != null) | ||
return false; | ||
} else if (!localName.equals(other.localName)) | ||
return false; | ||
if (namespace == null) { | ||
if (other.namespace != null) | ||
return false; | ||
} else if (!namespace.equals(other.namespace)) | ||
return false; | ||
return true; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return localName; | ||
} | ||
|
||
public static AxiomIdentifier axiom(String identifier) { | ||
return new AxiomIdentifier(AXIOM_NAMESPACE, identifier); | ||
} | ||
|
||
public static AxiomIdentifier from(String namespace, String localName) { | ||
return new AxiomIdentifier(namespace, localName); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
infra/axiom/src/main/java/com/evolveum/axiom/concepts/Lazy.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,45 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.axiom.concepts; | ||
|
||
public class Lazy<T> implements java.util.function.Supplier<T> { | ||
|
||
private static final Lazy NULL = Lazy.instant(null); | ||
private Object value; | ||
|
||
private Lazy(Object supplier) { | ||
value = supplier; | ||
} | ||
|
||
public static final <T> Lazy<T> from(Supplier<? extends T> supplier) { | ||
return new Lazy<>(supplier); | ||
} | ||
|
||
|
||
public static <T> Lazy<T> instant(T value) { | ||
return new Lazy<T>(value); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> Lazy<T> nullValue() { | ||
return NULL; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public T get() { | ||
if(value instanceof Supplier<?>) { | ||
value = ((Supplier<?>) value).get(); | ||
} | ||
return (T) value; | ||
} | ||
|
||
public interface Supplier<T> extends java.util.function.Supplier<T> { | ||
|
||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
infra/axiom/src/main/java/com/evolveum/axiom/concepts/Optionals.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,16 @@ | ||
package com.evolveum.axiom.concepts; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Optional; | ||
|
||
public class Optionals { | ||
|
||
public static <V> Optional<V>first(Collection<V> collection) { | ||
if(collection.isEmpty()) { | ||
return Optional.empty(); | ||
} | ||
return Optional.ofNullable(collection.iterator().next()); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomBaseDefinition.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,15 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.axiom.lang.api; | ||
|
||
import com.evolveum.axiom.api.AxiomIdentifier; | ||
|
||
public interface AxiomBaseDefinition { | ||
|
||
AxiomIdentifier name(); | ||
String documentation(); | ||
} |
Oops, something went wrong.