LightJason - AgentSpeak(L++)
CMutexVariable.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.language.variable;
25 
27 
28 import javax.annotation.Nonnull;
29 import javax.annotation.Nullable;
30 import java.util.Objects;
31 
32 
38 public class CMutexVariable<T> extends CVariable<T>
39 {
43  private static final long serialVersionUID = 9040218112516254186L;
44 
50  public CMutexVariable( final String p_functor )
51  {
52  super( p_functor );
53  }
54 
61  public CMutexVariable( final String p_functor, final T p_value )
62  {
63  super( p_functor, p_value );
64  }
65 
71  public CMutexVariable( final IPath p_functor )
72  {
73  super( p_functor );
74  }
75 
82  public CMutexVariable( @Nonnull final IPath p_functor, @Nullable final T p_value )
83  {
84  super( p_functor, p_value );
85  }
86 
87  @Nonnull
88  @Override
89  public final synchronized IVariable<T> set( final T p_value )
90  {
91  return super.set( p_value );
92  }
93 
94  @Override
95  public final synchronized <N> N raw()
96  {
97  return super.raw();
98  }
99 
100  @Nonnull
101  @Override
102  public final synchronized IVariable<T> thrownotallocated() throws IllegalStateException
103  {
104  return super.thrownotallocated();
105  }
106 
107  @Nonnull
108  @Override
109  public final synchronized IVariable<T> throwvaluenotassignableto( @Nonnull final Class<?>... p_class ) throws IllegalArgumentException
110  {
111  return super.throwvaluenotassignableto( p_class );
112  }
113 
114  @Override
115  public final synchronized boolean allocated()
116  {
117  return super.allocated();
118  }
119 
120  @Override
121  public final synchronized boolean valueassignableto( @Nonnull final Class<?>... p_class )
122  {
123  return super.valueassignableto( p_class );
124  }
125 
126  @Override
127  public final synchronized String toString()
128  {
129  return super.toString();
130  }
131 
132  @Nonnull
133  @Override
134  public IVariable<T> shallowcopy( @Nullable final IPath... p_prefix )
135  {
136  return ( Objects.isNull( p_prefix ) ) || ( p_prefix.length == 0 )
138  : new CMutexVariable<>( p_prefix[0].append( m_functor ), m_value );
139  }
140 
141  @Nonnull
142  @Override
144  {
145  return new CMutexVariable<>( m_functor.suffix(), m_value );
146  }
147 
148  @Override
149  public final boolean mutex()
150  {
151  return true;
152  }
153 }
final synchronized boolean valueassignableto( @Nonnull final Class<?>... p_class)
checkes assignable of the value
IVariable< T > set( @Nullable final T p_value)
sets the value
CMutexVariable( @Nonnull final IPath p_functor, @Nullable final T p_value)
ctor
final synchronized< N > N raw()
cast to any raw value type
IVariable< T > shallowcopy( @Nullable final IPath... p_prefix)
clones the object (shallow-copy)
CMutexVariable(final String p_functor, final T p_value)
ctor
final IPath m_functor
variable / functor name
Definition: CVariable.java:55
final synchronized IVariable< T > throwvaluenotassignableto( @Nonnull final Class<?>... p_class)
throws an illegal argument exception iif the value is not assignable to the class ...
IVariable< T > shallowcopysuffix()
clones the object (shallow-copy) without full-qualified path, only suffix is used ...
String suffix()
returns the last part of the path
final synchronized IVariable< T > thrownotallocated()
throws an illegal state exception iif the variable is not allocated
final synchronized boolean allocated()
returns allocated state
final boolean mutex()
flag to check if variable has is concurrency- / thread-safe