LightJason - AgentSpeak(L++)
IBuiltinAction.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.action.builtin;
25 
30 
31 import javax.annotation.Nonnull;
32 import java.util.Arrays;
33 import java.util.List;
34 import java.util.logging.Logger;
35 import java.util.stream.IntStream;
36 
37 
42 public abstract class IBuiltinAction extends IBaseAction
43 {
47  protected static final Logger LOGGER = CCommon.logger( IBuiltinAction.class );
51  private static final long serialVersionUID = 3888384147874966937L;
55  private final IPath m_name;
56 
57 
61  protected IBuiltinAction()
62  {
63  this( 2 );
64  }
65 
71  protected IBuiltinAction( final int p_length )
72  {
73  final List<String> l_names = Arrays.asList( this.getClass().getCanonicalName().split( "\\." ) );
74  l_names.set( l_names.size() - 1, l_names.get( l_names.size() - 1 ).substring( 1 ) );
75 
76  m_name = new CPath(
77  IntStream.range( Math.max( 0, l_names.size() - p_length ), l_names.size() )
78  .mapToObj( l_names::get )
79  ).lower();
80  }
81 
82  @Nonnull
83  @Override
84  public final IPath name()
85  {
86  return m_name;
87  }
88 
89 }
base class of build-in actions for setting name by package/classname (without prefix character) ...
default implementation of an action
class to create a path structure
Definition: CPath.java:53
Stream< String > stream()
stream over elements
static Logger logger(final Class<?> p_class)
returns a logger instance
final IPath name()
returns the name with path of the action