LightJason - AgentSpeak(L++)
IPath.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.common;
25 
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27 
28 import javax.annotation.Nonnull;
29 import java.io.Serializable;
30 import java.util.stream.Stream;
31 
32 
38 public interface IPath extends Serializable, Comparable<IPath>
39 {
43  String DEFAULTSEPERATOR = "/";
44 
48  IPath EMPTY = new IPath()
49  {
53  private static final long serialVersionUID = -8529008893337445887L;
54 
55  @Nonnull
56  @Override
57  public final IPath append( @Nonnull final IPath p_path )
58  {
59  return this;
60  }
61 
62  @Nonnull
63  @Override
64  public final IPath append( @Nonnull final String p_path )
65  {
66  return this;
67  }
68 
69  @Nonnull
70  @Override
71  public final IPath remove( final int p_index )
72  {
73  return this;
74  }
75 
76  @Nonnull
77  @Override
78  public final IPath remove( final int p_start, final int p_end )
79  {
80  return this;
81  }
82 
83  @Override
84  public final boolean endswith( @Nonnull final IPath p_path )
85  {
86  return false;
87  }
88 
89  @Override
90  public final boolean empty()
91  {
92  return true;
93  }
94 
95  @Nonnull
96  @Override
97  public final String get( final int p_index )
98  {
99  return "";
100  }
101 
102  @Nonnull
103  @Override
104  public final String path( final String p_separator )
105  {
106  return "";
107  }
108 
109  @Nonnull
110  @Override
111  public final String path()
112  {
113  return "";
114  }
115 
116  @Nonnull
117  @Override
118  public final String separator()
119  {
120  return "";
121  }
122 
123  @Nonnull
124  @Override
125  public final IPath separator( @Nonnull final String p_separator )
126  {
127  return this;
128  }
129 
130  @Nonnull
131  @Override
132  public final IPath lower()
133  {
134  return this;
135  }
136 
137  @Nonnull
138  @Override
139  public final IPath upper()
140  {
141  return this;
142  }
143 
144  @Nonnull
145  @Override
146  public final IPath subpath( final int p_fromindex )
147  {
148  return this;
149  }
150 
151  @Nonnull
152  @Override
153  public final IPath subpath( final int p_fromindex, final int p_toindex )
154  {
155  return this;
156  }
157 
158  @Nonnull
159  @Override
160  public final String suffix()
161  {
162  return "";
163  }
164 
165  @Nonnull
166  @Override
167  public final IPath pushback( @Nonnull final IPath p_path )
168  {
169  return this;
170  }
171 
172  @Nonnull
173  @Override
174  public final IPath pushback( @Nonnull final String p_path )
175  {
176  return this;
177  }
178 
179  @Nonnull
180  @Override
181  public final IPath pushfront( @Nonnull final String p_path )
182  {
183  return this;
184  }
185 
186  @Nonnull
187  @Override
188  public final IPath pushfront( @Nonnull final IPath p_path )
189  {
190  return this;
191  }
192 
193  @Nonnull
194  @Override
195  public final String removesuffix()
196  {
197  return "";
198  }
199 
200  @Nonnull
201  @Override
202  public final IPath reverse()
203  {
204  return this;
205  }
206 
207  @Override
208  public final int size()
209  {
210  return 0;
211  }
212 
213  @Override
214  public final boolean startswith( final IPath p_path )
215  {
216  return false;
217  }
218 
219  @Override
220  public final boolean startswith( final String p_path )
221  {
222  return false;
223  }
224 
225  @Nonnull
226  @Override
227  public final Stream<String> stream()
228  {
229  return Stream.empty();
230  }
231 
232  @Override
233  public final int compareTo( @Nonnull final IPath p_path )
234  {
235  return Integer.compare( p_path.hashCode(), this.hashCode() );
236  }
237 
238  @Override
239  public final int hashCode()
240  {
241  return 0;
242  }
243 
244  @Override
245  @SuppressFBWarnings( "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS" )
246  public final boolean equals( final Object p_object )
247  {
248  return ( ( p_object instanceof IPath ) && ( this.hashCode() == p_object.hashCode() ) )
249  || ( ( p_object instanceof String ) && ( this.path().hashCode() == p_object.hashCode() ) );
250  }
251  };
252 
259  @Nonnull
260  IPath append( @Nonnull final IPath p_path );
261 
268  @Nonnull
269  IPath append( @Nonnull final String p_path );
270 
277  @Nonnull
278  IPath remove( final int p_index );
279 
287  @Nonnull
288  IPath remove( final int p_start, final int p_end );
289 
296  boolean endswith( @Nonnull final IPath p_path );
297 
303  boolean empty();
304 
311  @Nonnull
312  String get( final int p_index );
313 
320  @Nonnull
321  String path( final String p_separator );
322 
328  @Nonnull
329  String path();
330 
336  @Nonnull
337  String separator();
338 
345  @Nonnull
346  IPath separator( @Nonnull final String p_separator );
347 
353  @Nonnull
354  IPath lower();
355 
361  @Nonnull
362  IPath upper();
363 
370  @Nonnull
371  IPath subpath( final int p_fromindex );
372 
380  @Nonnull
381  IPath subpath( final int p_fromindex, final int p_toindex );
382 
388  @Nonnull
389  String suffix();
390 
397  @Nonnull
398  IPath pushback( @Nonnull final IPath p_path );
399 
406  @Nonnull
407  IPath pushback( @Nonnull final String p_path );
408 
415  @Nonnull
416  IPath pushfront( @Nonnull final String p_path );
417 
424  @Nonnull
425  IPath pushfront( @Nonnull final IPath p_path );
426 
432  @Nonnull
433  String removesuffix();
434 
440  @Nonnull
441  IPath reverse();
442 
448  int size();
449 
456  boolean startswith( final IPath p_path );
457 
464  boolean startswith( final String p_path );
465 
471  @Nonnull
472  Stream<String> stream();
473 
474 }
String DEFAULTSEPERATOR
default seperator
Definition: IPath.java:43
IPath upper()
changes all elements to uppercase
boolean endswith( @Nonnull final IPath p_path)
check of a path ends with another path
IPath subpath(final int p_fromindex)
creates a path of the start index until the end
String removesuffix()
remove the suffix from the path
String path()
returns the full path as string
IPath pushfront( @Nonnull final String p_path)
adds a path at the front
Stream< String > stream()
stream over elements
boolean startswith(final IPath p_path)
check of a path starts with another path
boolean empty()
check if the path is empty
IPath append( @Nonnull final IPath p_path)
appends a path at the current and returns a new object
IPath pushback( @Nonnull final IPath p_path)
adds a path at the end
String suffix()
returns the last part of the path
IPath lower()
changes all elements to lower-case
String separator()
returns the separator
int size()
returns the number of path elements