24 package org.lightjason.agentspeak.action.builtin.web.graphql;
30 import javax.annotation.Nonnull;
31 import java.text.MessageFormat;
32 import java.util.Collection;
33 import java.util.stream.Collectors;
34 import java.util.stream.Stream;
66 return MessageFormat.format(
"'{'{0}'}'",
root( p_argument.raw() ) );
78 if ( p_literal.emptyValues() )
79 return p_literal.functor();
81 final String l_query =
values( p_literal.values() );
82 final String l_fields =
fields( p_literal.values() );
84 return MessageFormat.format(
86 p_literal.functor(), l_query.isEmpty() ?
"" : MessageFormat.format(
"({0})", l_query ),
87 l_fields.isEmpty() ?
"" : MessageFormat.format(
"'{'{0}'}'", l_fields )
98 private static String
values( @Nonnull
final Stream<ITerm> p_stream )
100 return p_stream.filter( i -> i instanceof
ILiteral )
101 .map(
ITerm::<ILiteral>raw )
105 .collect( Collectors.joining(
" " ) )
116 private static String
fields( @Nonnull
final Stream<ITerm> p_stream )
118 return p_stream.filter( i -> i instanceof
ILiteral )
119 .map(
ITerm::<ILiteral>raw )
120 .filter( i -> i.values().noneMatch( j -> j instanceof
IRawTerm ) )
124 .collect( Collectors.joining(
" " ) )
136 return p_literal.values()
141 .map( i -> p_literal.functor() +
" : " + i )
153 if ( p_value instanceof String )
154 return MessageFormat.format(
"\"{0}\"", p_value );
156 if ( p_value instanceof Collection<?> )
157 return MessageFormat.format(
162 return p_value.toString();
static String typeformat(final Object p_value)
type mapping
action to run graphql query by a literal.
static final long serialVersionUID
serial id
String functor()
returns the functor without path
static String fields( @Nonnull final Stream< ITerm > p_stream)
creates the field list
static String root( @Nonnull final ILiteral p_literal)
converts a literal query structure
< T > T raw()
cast to any raw value type
static String valueformat( @Nonnull final ILiteral p_literal)
format query argument
final String argumentquery( @Nonnull final ITerm p_argument)
static String values( @Nonnull final Stream< ITerm > p_stream)
argument values