-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (modl): Initial outline of future Java model
- Loading branch information
Showing
17 changed files
with
326 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2024 The Enola <https://enola.dev> Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 dev.enola.model.enola.java; | ||
|
||
import org.junit.Test; | ||
|
||
public class ModelTest { | ||
|
||
@Test | ||
public void model() {} | ||
} |
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,28 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2024 The Enola <https://enola.dev> Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 dev.enola.model.enola.java; | ||
|
||
import dev.enola.model.w3.rdfs.HasLabel; | ||
import dev.enola.model.w3.rdfs.Typed; | ||
import dev.enola.thing.java.IRI; | ||
|
||
/** 📦 <a href="https://docs.enola.dev/models/enola.dev/java/package/">Java Package</a>. */ | ||
@IRI("https://enola.dev/java/Package/{FQN}") | ||
public interface Package | ||
extends Typed, HasLabel { // NOT dev.enola.model.w3.rdfs.Class; these are the instances | ||
} |
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,71 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2024 The Enola <https://enola.dev> Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 dev.enola.model.enola.java; | ||
|
||
import dev.enola.model.w3.rdfs.HasLabel; | ||
import dev.enola.thing.Thing; | ||
import dev.enola.thing.java.IRI; | ||
import dev.enola.thing.java.JThing; | ||
|
||
/** | ||
* ☕ <a href="https://docs.enola.dev/models/enola.dev/java/type/">Java Type</a>. | ||
* | ||
* <p>Type (Class, Interface, Enum, Record, Primitives, Array, Void) in the Java Virtual Machine | ||
* (JVM). | ||
*/ | ||
@JThing("https://enola.dev/java/type") | ||
// ? @IRI("https://enola.dev/java/type/{FQN}") | ||
public interface Type | ||
extends /*Typed,*/ HasLabel { // NOT dev.enola.model.w3.rdfs.Class; these are the instances | ||
|
||
@IRI("https://enola.dev/java/package") | ||
Package pkg(); | ||
|
||
@IRI("https://enola.dev/java/type-kind") | ||
Kind kind(); | ||
|
||
@IRI("https://enola.dev/code/uses") | ||
Iterable<Type> uses(); | ||
|
||
@IRI("https://enola.dev/code/oop/parents") // parents extends #uses | ||
Iterable<Type> parents(); | ||
|
||
// TODO How to best do enums with (RDF) Things? | ||
enum Kind { | ||
Class, | ||
Interface, | ||
Enum, | ||
Record, | ||
Primitives, | ||
Array, | ||
Void | ||
} | ||
|
||
interface Builder<B extends Type> extends Thing.Builder<B> { // skipcq: JAVA-E0169 | ||
|
||
Builder<B> label(String label); | ||
|
||
Builder<B> pkg(Package pkg); | ||
|
||
Builder<B> kind(Kind kind); | ||
|
||
Builder<B> addUses(Type uses); | ||
|
||
Builder<B> addParents(Type parents); | ||
} | ||
} |
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,99 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2024 The Enola <https://enola.dev> Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 dev.enola.model.enola.java.gen; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
import dev.enola.model.enola.java.Package; | ||
import dev.enola.model.enola.java.Type; | ||
import dev.enola.thing.KIRI; | ||
import dev.enola.thing.impl.ImmutableThing; | ||
|
||
public class ImmutableType extends ImmutableThing implements Type { | ||
|
||
// TODO This, and similar, classes should (eventually) be automagically code generated... | ||
|
||
@Override | ||
public Package pkg() { | ||
return get("https://enola.dev/java/package", Package.class); | ||
} | ||
|
||
@Override | ||
public Kind kind() { | ||
return get("https://enola.dev/java/type-kind", Kind.class); | ||
} | ||
|
||
@Override | ||
public Iterable<Type> uses() { | ||
return get("https://enola.dev/code/uses", Iterable.class); | ||
// TODO new TypeToken<Iterable<Type>>() {}; | ||
} | ||
|
||
@Override | ||
public Iterable<Type> parents() { | ||
return get("https://enola.dev/code/oop/parents", Iterable.class); | ||
// TODO new TypeToken<Iterable<Type>>() {}; | ||
} | ||
|
||
protected ImmutableType( | ||
String iri, | ||
ImmutableMap<String, Object> properties, | ||
ImmutableMap<String, String> datatypes) { | ||
super(iri, properties, datatypes); | ||
} | ||
|
||
// skipcq: JAVA-E0169 | ||
public static class Builder<B extends ImmutableType> extends ImmutableThing.Builder<B> | ||
implements Type.Builder<B> { | ||
|
||
Builder() { | ||
super(); | ||
set(KIRI.RDF.TYPE, "https://enola.dev/java/type"); | ||
} | ||
|
||
@Override | ||
public Type.Builder<B> pkg(Package pkg) { | ||
set("https://enola.dev/java/package", pkg); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Type.Builder<B> label(String name) { | ||
set(KIRI.RDFS.LABEL, name); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Type.Builder<B> kind(Kind kind) { | ||
set("https://enola.dev/java/type-kind", kind); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Type.Builder<B> addUses(Type uses) { | ||
// TODO add() to ImmutableList.Builder ... created in constructor? | ||
return this; | ||
} | ||
|
||
@Override | ||
public Type.Builder<B> addParents(Type parents) { | ||
// TODO add() to ImmutableList.Builder ... created in constructor? | ||
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2024 The Enola <https://enola.dev> Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 dev.enola.thing.java; | ||
|
||
public @interface JThing { | ||
String value(); | ||
} |
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.