| /*=============================================================================# |
| # Copyright (c) 2014, 2018 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.internal.redocs.wikitext.r.ui.processing; |
| |
| import org.eclipse.core.resources.IFile; |
| import org.eclipse.core.runtime.jobs.ISchedulingRule; |
| |
| |
| public class DocumentRule implements ISchedulingRule { |
| |
| |
| private final IFile sweaveFile; |
| |
| |
| public DocumentRule(final IFile sweaveFile) { |
| if (sweaveFile == null) { |
| throw new NullPointerException("sweaveFile"); //$NON-NLS-1$ |
| } |
| this.sweaveFile= sweaveFile; |
| } |
| |
| |
| private boolean equalRule(final DocumentRule other) { |
| return (this.sweaveFile.equals(other.sweaveFile)); |
| } |
| |
| @Override |
| public boolean contains(final ISchedulingRule rule) { |
| return (rule instanceof DocumentRule && equalRule((DocumentRule) rule)); |
| } |
| |
| @Override |
| public boolean isConflicting(final ISchedulingRule rule) { |
| return (rule instanceof DocumentRule && equalRule((DocumentRule) rule)); |
| } |
| |
| |
| @Override |
| public int hashCode() { |
| return this.sweaveFile.hashCode() + 9543; |
| } |
| |
| @Override |
| public boolean equals(final Object obj) { |
| return (this == obj |
| || (obj instanceof DocumentRule && equalRule((DocumentRule) obj)) ); |
| } |
| |
| } |