blob: d38bb2aefe8ef218a12e528c30b2ebd36ee613f0 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2008, 2019 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.ltk.issues.core;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
/**
* BasicProblem in a source unit. Default implementation of {@link Problem}.
*/
@NonNullByDefault
public class BasicProblem implements Problem {
private final int line;
private final int startOffset;
private final int endOffset;
private final String modelTypeId;
private final int severity;
private final int code;
private final String message;
public BasicProblem(final String modelTypeId,
final int severity, final int code, final String message,
final int line, final int startOffset, final int endOffset) {
this.modelTypeId= modelTypeId;
this.severity= severity;
this.code= code;
this.message= message;
this.line= line;
this.startOffset= startOffset;
this.endOffset= (endOffset - startOffset > 0) ? endOffset : startOffset + 1;
}
public BasicProblem(final String modelTypeId,
final int severity, final int code, final String message,
final int startOffset, final int endOffset) {
this.modelTypeId= modelTypeId;
this.severity= severity;
this.code= code;
this.message= message;
this.line= -1;
this.startOffset= startOffset;
this.endOffset= (endOffset - startOffset > 0) ? endOffset : startOffset + 1;
}
@Override
public String getCategoryId() {
return this.modelTypeId;
}
@Override
public int getSourceLine() {
return this.line;
}
@Override
public int getSourceStartOffset() {
return this.startOffset;
}
@Override
public int getSourceEndOffset() {
return this.endOffset;
}
@Override
public int getSeverity() {
return this.severity;
}
@Override
public int getCode() {
return this.code;
}
@Override
public String getMessage() {
return this.message;
}
}