001/* 002 * SPDX-License-Identifier: Apache-2.0 003 * 004 * Copyright 2024-2026 The Enola <https://enola.dev> Authors 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package dev.enola.zimpl; 019 020import com.google.common.collect.ImmutableList; 021 022import dev.enola.Action; 023import dev.enola.Enola; 024import dev.enola.common.convert.IdentityObjectWithTypeConverter; 025import dev.enola.common.convert.ObjectWithTypeTokenConverter; 026import dev.enola.common.convert.ObjectWithTypeTokenConverterChain; 027import dev.enola.common.io.resource.DataResource; 028import dev.enola.common.io.resource.EmptyResource; 029import dev.enola.common.io.resource.ResourceProviders; 030import dev.enola.data.ProviderFromIRI; 031import dev.enola.data.Repository; 032import dev.enola.data.RepositoryBuilder; 033import dev.enola.model.enola.action.Get; 034 035public class EnolaProvider { 036 037 private final ProviderFromIRI<?> objectProvider = 038 new ResourceProviders(new EmptyResource.Provider(), new DataResource.Provider()); 039 040 private final ObjectWithTypeTokenConverter converter = 041 new ObjectWithTypeTokenConverterChain( 042 ImmutableList.<ObjectWithTypeTokenConverter>builder() 043 .add(new IdentityObjectWithTypeConverter()) 044 .build()); 045 046 private final Repository<Action<?, ?>> actionsRepo = 047 new ActionRepositoryBuilder().store(new Get(objectProvider)).build(); 048 049 public Enola get() { 050 return new EnolaImplementation(actionsRepo, converter); 051 } 052 053 private static class ActionRepositoryBuilder extends RepositoryBuilder<Action<?, ?>> { 054 055 @Override 056 protected String getIRI(Action<?, ?> action) { 057 return action.iri(); 058 } 059 } 060}