// Path: src/main/java/com/nebhale/buildmonitor/domain/Build.java
// @Entity
// public final class Build {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private volatile Integer id;
// 
//     private volatile Date created;
// 
//     @JoinColumn(name = "project") // TODO: Remove once H2 supports column rename in PostgreSQL compatibility mode
//     @ManyToOne
//     @NotNull
//     private volatile Project project;
// 
//     @Size(min = 1, max = 256)
//     private volatile String uri;
// 
//     @NotNull
//     private volatile State state;
// 
//     Build() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param project the project that the build belongs to
//      * @param uri     the uri of the build
//      * @param state   the state of the build
//      */
//     public Build(Project project, String uri, State state) {
//         this.created = new Date();
//         this.project = project;
//         this.uri = uri;
//         this.state = state;
//     }
// 
//     /**
//      * Returns the id of the build
//      *
//      * @return the id of the build
//      */
//     @JsonIgnore
//     public Integer getId() {
//         return this.id;
//     }
// 
//     /**
//      * Returns the date that the build was created
//      *
//      * @return the date that the build was created
//      */
//     public Date getCreated() {
//         return this.created;
//     }
// 
//     /**
//      * Returns the project that the build belongs to
//      *
//      * @return the project that the build belongs to
//      */
//     @JsonIgnore
//     public Project getProject() {
//         return this.project;
//     }
// 
//     /**
//      * Returns the uri of the build
//      *
//      * @return the uri of the build
//      */
//     public String getUri() {
//         return this.uri;
//     }
// 
//     /**
//      * Returns the state of the build
//      *
//      * @return the state of the build
//      */
//     public State getState() {
//         return this.state;
//     }
// 
//     /**
//      * Set the state of the build
//      *
//      * @param state the state of the build
//      */
//     public void setState(State state) {
//         this.state = state;
//     }
// 
//     /**
//      * The state of a {@link Build}
//      */
//     public enum State {
// 
//         /**
//          * The build has failed
//          */
//         FAIL,
// 
//         /**
//          * The build is currently in progress
//          */
//         IN_PROGRESS,
// 
//         /**
//          * The build has passed
//          */
//         PASS,
// 
//         /**
//          * The build is in an unknown state
//          */
//         UNKNOWN
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/domain/Project.java
// @Entity
// public final class Project {
// 
//     @Id
//     @Size(min = 1, max = 8)
//     private volatile String key;
// 
//     @Size(min = 1, max = 64)
//     private volatile String name;
// 
//     Project() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param key  the key of the project
//      * @param name the name of the project
//      */
//     public Project(String key, String name) {
//         this.key = key.toUpperCase();
//         this.name = name;
//     }
// 
//     /**
//      * Returns the key of the project
//      *
//      * @return the key of the project
//      */
//     public String getKey() {
//         return this.key;
//     }
// 
//     /**
//      * Returns the name of the project
//      *
//      * @return the name of the project
//      */
//     public String getName() {
//         return this.name;
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/repository/BuildRepository.java
// public interface BuildRepository extends JpaRepository<Build, Integer> {
// 
//     /**
//      * Returns all builds belonging to a project sorted by their creation date, descending
//      *
//      * @param project  the project that the builds belong to
//      * @param pageable the paging configuration
//      *
//      * @return all builds belonging to a project sorted by their creation date, descending
//      */
//     Page<Build> findAllByProjectOrderByCreatedDesc(Project project, Pageable pageable);
// 
//     /**
//      * Returns a build uniquely identified by it's URI, otherwise {@literal null}
//      *
//      * @param uri the URI that uniquely identifies a build
//      *
//      * @return a build uniquely identified by it's URI, otherwise {@literal null}
//      */
//     Build findByUri(String uri);
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/web/resource/BuildResourceAssembler.java
// public interface BuildResourceAssembler extends ResourceAssembler<Build, Resource<Build>> {
// 
// }


import com.nebhale.buildmonitor.domain.Build;
import com.nebhale.buildmonitor.domain.Project;
import com.nebhale.buildmonitor.repository.BuildRepository;
import com.nebhale.buildmonitor.web.resource.BuildResourceAssembler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Resource;
import org.springframework.messaging.core.MessageSendingOperations;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/*
 * Copyright 2013-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nebhale.buildmonitor.web.notify;



@Component
final class MessagingBuildsChangedNotifier implements BuildsChangedNotifier {

    private static final Pageable PAGE = new PageRequest(0, 10);

    private final MessageSendingOperations<String> messageTemplate;

// Path: src/main/java/com/nebhale/buildmonitor/domain/Build.java
// @Entity
// public final class Build {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private volatile Integer id;
// 
//     private volatile Date created;
// 
//     @JoinColumn(name = "project") // TODO: Remove once H2 supports column rename in PostgreSQL compatibility mode
//     @ManyToOne
//     @NotNull
//     private volatile Project project;
// 
//     @Size(min = 1, max = 256)
//     private volatile String uri;
// 
//     @NotNull
//     private volatile State state;
// 
//     Build() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param project the project that the build belongs to
//      * @param uri     the uri of the build
//      * @param state   the state of the build
//      */
//     public Build(Project project, String uri, State state) {
//         this.created = new Date();
//         this.project = project;
//         this.uri = uri;
//         this.state = state;
//     }
// 
//     /**
//      * Returns the id of the build
//      *
//      * @return the id of the build
//      */
//     @JsonIgnore
//     public Integer getId() {
//         return this.id;
//     }
// 
//     /**
//      * Returns the date that the build was created
//      *
//      * @return the date that the build was created
//      */
//     public Date getCreated() {
//         return this.created;
//     }
// 
//     /**
//      * Returns the project that the build belongs to
//      *
//      * @return the project that the build belongs to
//      */
//     @JsonIgnore
//     public Project getProject() {
//         return this.project;
//     }
// 
//     /**
//      * Returns the uri of the build
//      *
//      * @return the uri of the build
//      */
//     public String getUri() {
//         return this.uri;
//     }
// 
//     /**
//      * Returns the state of the build
//      *
//      * @return the state of the build
//      */
//     public State getState() {
//         return this.state;
//     }
// 
//     /**
//      * Set the state of the build
//      *
//      * @param state the state of the build
//      */
//     public void setState(State state) {
//         this.state = state;
//     }
// 
//     /**
//      * The state of a {@link Build}
//      */
//     public enum State {
// 
//         /**
//          * The build has failed
//          */
//         FAIL,
// 
//         /**
//          * The build is currently in progress
//          */
//         IN_PROGRESS,
// 
//         /**
//          * The build has passed
//          */
//         PASS,
// 
//         /**
//          * The build is in an unknown state
//          */
//         UNKNOWN
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/domain/Project.java
// @Entity
// public final class Project {
// 
//     @Id
//     @Size(min = 1, max = 8)
//     private volatile String key;
// 
//     @Size(min = 1, max = 64)
//     private volatile String name;
// 
//     Project() {
//     }
// 
//     /**
//      * Creates a new instance
//      *
//      * @param key  the key of the project
//      * @param name the name of the project
//      */
//     public Project(String key, String name) {
//         this.key = key.toUpperCase();
//         this.name = name;
//     }
// 
//     /**
//      * Returns the key of the project
//      *
//      * @return the key of the project
//      */
//     public String getKey() {
//         return this.key;
//     }
// 
//     /**
//      * Returns the name of the project
//      *
//      * @return the name of the project
//      */
//     public String getName() {
//         return this.name;
//     }
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/repository/BuildRepository.java
// public interface BuildRepository extends JpaRepository<Build, Integer> {
// 
//     /**
//      * Returns all builds belonging to a project sorted by their creation date, descending
//      *
//      * @param project  the project that the builds belong to
//      * @param pageable the paging configuration
//      *
//      * @return all builds belonging to a project sorted by their creation date, descending
//      */
//     Page<Build> findAllByProjectOrderByCreatedDesc(Project project, Pageable pageable);
// 
//     /**
//      * Returns a build uniquely identified by it's URI, otherwise {@literal null}
//      *
//      * @param uri the URI that uniquely identifies a build
//      *
//      * @return a build uniquely identified by it's URI, otherwise {@literal null}
//      */
//     Build findByUri(String uri);
// 
// }
// 
// Path: src/main/java/com/nebhale/buildmonitor/web/resource/BuildResourceAssembler.java
// public interface BuildResourceAssembler extends ResourceAssembler<Build, Resource<Build>> {
// 
// }


// Path: src/main/java/com/nebhale/buildmonitor/web/notify/MessagingBuildsChangedNotifier.java
import com.nebhale.buildmonitor.domain.Build;
import com.nebhale.buildmonitor.domain.Project;
import com.nebhale.buildmonitor.repository.BuildRepository;
import com.nebhale.buildmonitor.web.resource.BuildResourceAssembler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Resource;
import org.springframework.messaging.core.MessageSendingOperations;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/*
 * Copyright 2013-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nebhale.buildmonitor.web.notify;



@Component
final class MessagingBuildsChangedNotifier implements BuildsChangedNotifier {

    private static final Pageable PAGE = new PageRequest(0, 10);

    private final MessageSendingOperations<String> messageTemplate;

    private final BuildRepository repository;