QueryUtils { public static String convertCollectionValue( String value ) { if ( StringUtils.isEmpty( value ) ) { throw new QueryParserException( "Value is null" ); } if ( !value.startsWith( "[" ) || !value.endsWith( "]" ) ) { throw new QueryParserException( "Invalid query value" ); } String[] split = value.substring( 1, value.length() - 1 ).split( "," ); List<String> items = Lists.newArrayList( split ); String str = "("; for ( int i = 0; i < items.size(); i++ ) { Object item = QueryUtils.parseValue( items.get( i ) ); if ( item != null ) { str += item; if ( i < items.size() - 1 ) { str += ","; } } } str += ")"; return str; }  static T parseValue( Class<T> klass, Object objectValue ); @SuppressWarnings( "unchecked" ) static T parseValue( Class<T> klass, Class<?> secondaryKlass, Object objectValue ); @SuppressWarnings( { "unchecked", "rawtypes" } ) static T getEnumValue( Class<T> klass, String value ); static Object parseValue( String value ); static String parseSelectFields( List<String> fields ); static String convertCollectionValue( String value ); static String parseFilterOperator( String operator, String value ); @Nonnull static List<Order> convertOrderStrings( @Nullable Collection<String> orders, @Nonnull Schema schema ); static T getSingleResult( TypedQuery<T> query );  }
@Test public void testTransformCollectionValue() { assertEquals( "('x','y')", QueryUtils.convertCollectionValue( "[x,y]" ) ); assertEquals( "(1,2)", QueryUtils.convertCollectionValue( "[1,2]" ) ); }