All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sarl.api.naming.namespace.NamespaceService Maven / Gradle / Ivy

The newest version!
/**
 * $Id$
 * 
 * SARL is an general-purpose agent programming language.
 * More details on http://www.sarl.io
 * 
 * Copyright (C) 2014-2024 SARL.io, the Original Authors and Main 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
 * 
 *      http://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 io.sarl.api.naming.namespace;

import io.sarl.api.naming.name.SarlName;
import io.sarl.api.naming.parser.INameParser;
import io.sarl.lang.core.annotation.SarlElementType;
import io.sarl.lang.core.annotation.SarlSpecification;
import java.net.URI;
import org.arakhne.afc.services.IService;
import org.eclipse.xtext.xbase.lib.Pure;
import org.eclipse.xtext.xbase.lib.XbaseGenerated;

/**
 * This service enables to manage the name spaces into the SRE.
 * 
 * 

Each object within the SRE may be identified by a name, stored into an {@link SarlName}. * * @author Stéphane Galland * @version api.naming 0.14.0 20241106-161408 * @mavengroupid io.sarl.sdk * @mavenartifactid api.naming * @since 0.12 */ @SarlSpecification("0.14") @SarlElementType(11) @XbaseGenerated @SuppressWarnings("all") public interface NamespaceService extends IService { /** * Replies the name parser that is used by this service. * * @return The name parser * @since 0.11 */ @Pure INameParser getNameParser(); /** * Replies the validator for the access to the fields that is used by this service. * * @return The field access validator. * @since 0.12 */ @Pure IFieldAccessValidator getFieldAccessValidator(); /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the root context. A {@code null} value is replied if the object is not found. */ @Pure T findObject(final SarlName name, final Class type); /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the object with the given name. A {@code null} value is replied if the object is not found. */ @Pure Object findObject(final SarlName name); /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the root context. A {@code null} value is replied if the object is not found. * @since 0.11 */ @Pure default T findObject(final String name, final Class type) { INameParser parser = this.getNameParser(); URI nameURI = parser.decode(name); if ((nameURI == null)) { return null; } SarlName sarlName = parser.decode(nameURI); if ((sarlName == null)) { return null; } return this.findObject(sarlName, type); } /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the object with the given name. A {@code null} value is replied if the object is not found. * @since 0.11 */ @Pure default Object findObject(final String name) { INameParser parser = this.getNameParser(); URI nameURI = parser.decode(name); if ((nameURI == null)) { return null; } SarlName sarlName = parser.decode(nameURI); if ((sarlName == null)) { return null; } return this.findObject(sarlName); } /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the root context. A {@code null} value is replied if the object is not found. * @since 0.12 */ @Pure default T findObject(final URI name, final Class type) { INameParser parser = this.getNameParser(); SarlName sarlName = parser.decode(name); if ((sarlName == null)) { return null; } return this.findObject(sarlName, type); } /** * Finds and replies the object with the given name and of the given type. * * @param name the name of the object. See the documentation of {@link NamespaceService} * for details. * @return the object with the given name. A {@code null} value is replied if the object is not found. * @since 0.12 */ @Pure default Object findObject(final URI name) { INameParser parser = this.getNameParser(); SarlName sarlName = parser.decode(name); if ((sarlName == null)) { return null; } return this.findObject(sarlName); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy