public static ListRepresentation list( Collection<Neo4jError> errors ) { return new ListRepresentation( "error-list", new IterableWrapper<ErrorEntryRepresentation, Neo4jError>( errors ) { @Override protected ErrorEntryRepresentation underlyingObjectToObject( Neo4jError error ) { return new ErrorEntryRepresentation( error ); } } ); } }
public static ListRepresentation strings( String... values ) { return string( Arrays.asList( values ) ); }
@Override protected Representation dispatchStringArrayProperty( String[] property, Void param ) { return ListRepresentation.strings( property ); }
final void serialize( ListWriter list, ListRepresentation value ) { value.serialize( new ListSerializer( list, baseUri, extensions ) ); list.done(); }
@Override protected Representation dispatchPointArrayProperty( Point[] property, Void param ) { return ListRepresentation.points( property ); }
public static ListRepresentation points( Point... values ) { return point( Arrays.asList( values ) ); }
@Override String serialize( RepresentationFormat format, URI baseUri, ExtensionInjector extensions ) { ListWriter writer = format.serializeList( type ); serialize( new ListSerializer( writer, baseUri, extensions ) ); writer.done(); return format.complete( writer ); }
@Override protected Representation dispatchPointArrayProperty( Point[] property, Void param ) { return ListRepresentation.points( property ); }
public static ListRepresentation points( Point... values ) { return point( Arrays.asList( values ) ); }
public static ListRepresentation point( Iterable<Point> values ) { return new ListRepresentation( RepresentationType.POINT, new IterableWrapper<Representation, Point>( values ) { @Override protected Representation underlyingObjectToObject( Point value ) { return ValueRepresentation.point( value ); } } ); }
public ListRepresentation getNodeLabels( long nodeId ) throws NodeNotFoundException { Iterable<String> labels = new IterableWrapper<String,Label>( node( nodeId ).getLabels() ) { @Override protected String underlyingObjectToObject( Label object ) { return object.name(); } }; return ListRepresentation.string( labels ); }
@GET @Path( DOMAINS_PATH ) public Response listDomains() throws NullPointerException { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ListRepresentation domains = ListRepresentation.strings( server.getDomains() ); return output.ok( domains ); }
public static List<Object> serialize( URI baseUri, ListRepresentation repr ) { List<Object> result = new ArrayList<>(); repr.serialize( new ListSerializer( new ListWrappingWriter( result ), baseUri, null ) ); return result; }
@Mapping( "beans" ) public ListRepresentation getBeans() { return new ListRepresentation( "bean", beans ); }
@Override public void serialize( MappingSerializer serializer ) { super.serialize( serializer ); serializer.putList( "engines", ListRepresentation.string( engines ) ); }
@Test public void canFormatListOfStrings() { json.assemble( ListRepresentation.strings( "hello", "world" ) ); String expectedString = JsonHelper.createJsonFrom( Arrays.asList( "hello", "world" ) ); assertEquals( expectedString, stream.toString() ); }
final void serialize( ListWriter list, ListRepresentation value ) { value.serialize( new ListSerializer( list, baseUri, extensions ) ); list.done(); }
public static ListRepresentation string( Iterable<String> values ) { return new ListRepresentation( RepresentationType.STRING, new IterableWrapper<Representation, String>( values ) { @Override protected Representation underlyingObjectToObject( String value ) { return ValueRepresentation.string( value ); } } ); }
public Representation getAutoIndexedProperties( String type ) { AutoIndexer<? extends PropertyContainer> indexer = getAutoIndexerForType( type ); return ListRepresentation.string( indexer.getAutoIndexedProperties() ); }
@Test public void canFormatListOfStrings() { String entity = json.assemble( ListRepresentation.strings( "hello", "world" ) ); String expectedString = JsonHelper.createJsonFrom( Arrays.asList( "hello", "world" ) ); assertEquals( expectedString, entity ); }