-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This includes only indirectly related work, such as: * Add check-jsonschema pre-commit
- Loading branch information
Showing
50 changed files
with
4,602 additions
and
46 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
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,21 @@ | ||
# 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. | ||
|
||
# https://yamllint.readthedocs.io/en/stable/configuration.html | ||
|
||
rules: | ||
# Let's just check this only via .editorconfig instead | ||
line-length: disable |
20 changes: 20 additions & 0 deletions
20
core/impl/src/main/java/dev/enola/core/AbstractRepository.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,20 @@ | ||
/* | ||
* 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.core; | ||
|
||
public abstract class AbstractRepository {} |
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
78 changes: 78 additions & 0 deletions
78
core/impl/src/main/java/dev/enola/core/type/TypeRepository.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,78 @@ | ||
/* | ||
* 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.core.type; | ||
|
||
import com.google.common.collect.ImmutableSortedMap; | ||
import com.google.protobuf.TypeRegistry; | ||
|
||
import dev.enola.core.meta.proto.Type; | ||
|
||
/** | ||
* Repository of {@link Type}. | ||
* | ||
* <p>Not to be confused with {@link TypeRegistry}. | ||
*/ | ||
public class TypeRepository { | ||
// TODO Extract what's general here to share with PropertyRepository et al. | ||
|
||
private final ImmutableSortedMap<String, Type> types; | ||
|
||
private TypeRepository(ImmutableSortedMap<String, Type> types) { | ||
this.types = types; | ||
} | ||
|
||
public Iterable<Type> list() { | ||
return types.values(); | ||
} | ||
|
||
public Iterable<String> names() { | ||
return types.keySet(); | ||
} | ||
|
||
public Type getByName(String name) { | ||
return types.get(name); | ||
} | ||
|
||
public static Builder newBuilder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private final ImmutableSortedMap.Builder<String, Type> types = | ||
ImmutableSortedMap.naturalOrder(); | ||
|
||
public void add(Type.Builder type) { | ||
require(type.getUri(), "uri"); | ||
// TODO setUrl(...), based on some sort of baseURL to the Web UI | ||
var name = require(type.getName(), "name"); | ||
types.put(name, type.build()); | ||
} | ||
|
||
public TypeRepository build() { | ||
return new TypeRepository(types.build()); | ||
} | ||
|
||
private <T> T require(T what, String identification) { | ||
if (what == null) | ||
throw new IllegalArgumentException("Type '" + identification + "' is required"); | ||
return what; | ||
} | ||
|
||
private Builder() {} | ||
} | ||
} |
Oops, something went wrong.