org.jumpmind.symmetric.model.NodeGroupChannelWindow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symmetric-ds Show documentation
Show all versions of symmetric-ds Show documentation
SymmetricDS is an open source database synchronization solution. It is platform-independent,
web-enabled, and database-agnostic. SymmetricDS was first built to replicate changes between 'retail store'
databases and ad centralized 'corporate' database.
The newest version!
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* .
*
* 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 org.jumpmind.symmetric.model;
import java.sql.Time;
import java.util.Date;
import org.apache.commons.lang.time.FastDateFormat;
import org.jumpmind.symmetric.util.AppUtils;
/**
*
*/
public class NodeGroupChannelWindow {
private String nodeGroupId;
private String channelId;
private Time startTime;
private Time endTime;
private boolean enabled;
final FastDateFormat HHmmss = FastDateFormat.getInstance("HH:mm:ss");
public String getNodeGroupId() {
return nodeGroupId;
}
public void setNodeGroupId(String nodeGroupId) {
this.nodeGroupId = nodeGroupId;
}
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public Time getStartTime() {
return startTime;
}
public void setStartTime(Time startTime) {
this.startTime = startTime;
}
public Time getEndTime() {
return endTime;
}
public void setEndTime(Time endTime) {
this.endTime = endTime;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isEnabled() {
return enabled;
}
public boolean inTimeWindow(Date date) {
Time time = Time.valueOf(HHmmss.format(date));
return inTimeWindow(time);
}
public boolean inTimeWindow(Time time) {
if (enabled) {
return (startTime.before(time) && endTime.after(time))
|| (startTime.before(time) && endTime.before(startTime))
|| (endTime.after(time) && startTime.after(endTime));
} else {
return true;
}
}
public boolean inTimeWindow(String timezoneOffset) {
return inTimeWindow(AppUtils.getLocalDateForOffset(timezoneOffset));
}
}