001/* 002 * Copyright 2012-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.devtools.classpath; 018 019import java.util.Set; 020 021import org.springframework.boot.devtools.filewatch.ChangedFiles; 022import org.springframework.context.ApplicationEvent; 023import org.springframework.util.Assert; 024 025/** 026 * {@link ApplicationEvent} containing details of a classpath change. 027 * 028 * @author Phillip Webb 029 * @since 1.3.0 030 * @see ClassPathFileChangeListener 031 */ 032public class ClassPathChangedEvent extends ApplicationEvent { 033 034 private final Set<ChangedFiles> changeSet; 035 036 private final boolean restartRequired; 037 038 /** 039 * Create a new {@link ClassPathChangedEvent}. 040 * @param source the source of the event 041 * @param changeSet the changed files 042 * @param restartRequired if a restart is required due to the change 043 */ 044 public ClassPathChangedEvent(Object source, Set<ChangedFiles> changeSet, 045 boolean restartRequired) { 046 super(source); 047 Assert.notNull(changeSet, "ChangeSet must not be null"); 048 this.changeSet = changeSet; 049 this.restartRequired = restartRequired; 050 } 051 052 /** 053 * Return details of the files that changed. 054 * @return the changed files 055 */ 056 public Set<ChangedFiles> getChangeSet() { 057 return this.changeSet; 058 } 059 060 /** 061 * Return if an application restart is required due to the change. 062 * @return if an application restart is required 063 */ 064 public boolean isRestartRequired() { 065 return this.restartRequired; 066 } 067 068}