hydra-sample/service/src/main/java/de/escalon/hypermedia/sample/event/EventController.java
@RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<Resources<Event>> findEvents(@RequestParam(required = false) String name) {
        List<Event> events = assembler.toResources(eventBackend.getEvents());
        List<Event> matches = new ArrayList<Event>();
        for (Event event : events) {
            if (name == null || event.workPerformed.getContent().name.equals(name)) {
                addAffordances(event);
                matches.add(event);
            }
        }
        Resources<Event> eventResources = new Resources<Event>(matches);

        eventResources.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
                .addEvent(new Event(null, new CreativeWork(null), null, EventStatusType.EVENT_SCHEDULED)))
                .withSelfRel());

        eventResources.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
                .findEvents(null))
                .withRel("hydra:search"));

        return new ResponseEntity<Resources<Event>>(eventResources, HttpStatus.OK);
    }
@RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<Resources<Event>> findEvents(@RequestParam(required = false) String name) {
        List<Event> events = assembler.toResources(eventBackend.getEvents());
        List<Event> matches = new ArrayList<Event>();
        for (Event event : events) {
            if (name == null || event.workPerformed.getContent().name.equals(name)) {
                addAffordances(event);
                matches.add(event);
            }
        }
        Resources<Event> eventResources = new Resources<Event>(matches);

        eventResources.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
                .addEvent(new Event(null, new CreativeWork(null), null, EventStatusType.EVENT_SCHEDULED)))
                .withSelfRel());

        eventResources.add(AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(EventController.class)
                .findEvents(null))
                .withRel("hydra:search"));

        return new ResponseEntity<Resources<Event>>(eventResources, HttpStatus.OK);
    }
@ RequestMapping ( method = RequestMethod . GET ) @ ResponseBody public ResponseEntity < Resources < Event > > findEvents ( @ RequestParam ( required = false ) String name ) { List < Event > events = assembler . toResources ( eventBackend . getEvents ( ) ) ; List < Event > matches = new ArrayList < Event > ( ) ; for ( Event event : events ) { if ( name == null || event . workPerformed . getContent ( ) . name . equals ( name ) ) { addAffordances ( event ) ; matches . add ( event ) ; } } Resources < Event > eventResources = new Resources < Event > ( matches ) ; eventResources . add ( AffordanceBuilder . linkTo ( AffordanceBuilder . methodOn ( EventController . class ) . addEvent ( new Event ( null , new CreativeWork ( null ) , null , EventStatusType . EVENT_SCHEDULED ) ) ) . withSelfRel ( ) ) ; eventResources . add ( AffordanceBuilder . linkTo ( AffordanceBuilder . methodOn ( EventController . class ) . findEvents ( null ) ) . withRel ( "hydra:search" ) ) ; return new ResponseEntity < Resources < Event > > ( eventResources , HttpStatus . OK ) ; }
}
}